為了和python解釋器交互,控制台執行腳本後面添加變數import sysprint(sys.argv) def post(): print('upload')def download(): print('download')if sys.argv[1] == 'post': post()elif ...
為了和python解釋器交互,控制台執行腳本後面添加變數
import sys
print(sys.argv)
def post():
print('upload')
def download():
print('download')
if sys.argv[1] == 'post':
post()
elif sys.argv[1] == 'download':
download()
sys.exit(n) # 退出程式,0為正常
print(sys.path) # python使用模塊的路徑 ['F:\\python_code\\fullstack_s2\\week4\\day18','F:\\python_code\\fullstack_s2','F:\\python_code\\fullstack_s2\\week2','D:\\ProgramFiles\\python36\\python36.zip','D:\\ProgramFiles\\python36\\DLLs','D:\\ProgramFiles\\python36\\lib','D:\\ProgramFiles\\python36','D:\\ProgramFiles\\python36\\lib\\site-packages','D:\\ProgramFiles\\JetBrains\\PyCharm2017.3\\helpers\\pycharm_matplotlib_backend']
print(sys.platform) # win32 查看平臺
sys.stdout.write('#####') # 標準輸出