use python shell

1. show & change directory

>>> import os

>>> os.getcwd()

'/home/user'

>>> os.chdir("/tmp/")

>>> os.getcwd()

'/tmp'

2.  execute .py from shell

>>>import sys

>>>sys.argv = ['', 'arg1', 'arg2']

>>>execfile('myscript.py')

还有个什么subprocess的,没搞懂

你可能感兴趣的:(python)