019sys模块

为了和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('#####')        # 标准输出


posted @ 2017-12-29 00:30  Alos403  阅读(268)  评论(0编辑  收藏  举报