day22_2-sys模块
# ********************day22_2-sys模块 *******************
# ********************day22_2-sys模块 *******************
# ********************day22_2-sys模块 *******************# 参考资料:
# python模块(转自Yuan先生) - 狂奔__蜗牛 - 博客园
# https://www.cnblogs.com/guojintao/articles/9070485.html
# =====>>>>>>内容概览
# =====>>>>>>内容概览
# =====>>>>>>内容概览
'''
# ------------------------------------------------------------
# # 1、sys.argv ???
# # # 命令行参数List,第一个元素是程序本身路径
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 2、sys.exit(n) 退出程序,正常退出时exit(0)
# # # 退出程序,正常退出时exit(0)
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 3、sys.version
# # # 获取Python解释程序的版本信息
# # # ==>>>应用场景:当程序拷贝到其他的电脑的时候,需要进行对电脑的运行环境进行获取,
# # # 以保证程序在其他的操作系统环境下能够正常的运行
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 4、sys.maxint
# # # 最大的Int值 (python 2 中才有这个模块)
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 5、sys.path
# # # 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 6、sys.platform
# # # 返回操作系统平台名称
# # # ==>>>应用场景:当程序拷贝到其他的电脑的时候,需要进行对电脑的运行环境进行获取,
# # # 以保证程序在其他的操作系统环境下能够正常的运行
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 7、sys实例:进度条
# ------------------------------------------------------------
------------------------------------------------分割线-------------------------------------------------
------------------------------------------------分割线-------------------------------------------------
------------------------------------------------分割线-------------------------------------------------
''' # ------------------------------------------------------------ # # 1、sys.argv # # # 命令行参数List,第一个元素是程序本身路径 # # # Python中 sys.argv[]的用法简明解释 - CSDN博客 # # # https://blog.csdn.net/xu380393916/article/details/81486773 # ------------------------------------------------------------ ''' # # import sys # print(sys.argv) # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # ['D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py'] # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 2、sys.exit(n) 退出程序,正常退出时exit(0) # # # 退出程序,正常退出时exit(0) # ------------------------------------------------------------ ''' # # import sys # msg =''' # 1:输入 # 2:退出 # ''' # dic = { # "d_get":"1", # "d_exit":"2" # } # while True: # print(msg) # usr_input = input("请输入选项:") # if usr_input == dic["d_get"]: # continue # elif usr_input == dic["d_exit"]: # sys.exit(0) # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # # # 1:输入 # # 2:退出 # # # # 请输入选项:1 # # # # 1:输入 # # 2:退出 # # # # 请输入选项:1 # # # # 1:输入 # # 2:退出 # # # # 请输入选项:2 # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 3、sys.version # # # 获取Python解释程序的版本信息 # # # ==>>>应用场景:当程序拷贝到其他的电脑的时候,需要进行对电脑的运行环境进行获取, # # # 以保证程序在其他的操作系统环境下能够正常的运行 # ------------------------------------------------------------ ''' # # import sys # print(sys.version) # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 4、sys.maxint # # # 最大的Int值 (python 2 中才有这个模块) # ------------------------------------------------------------ ''' # 以下的环境是在python2.7中运运行的 # import sys # print(sys.maxint) # # # D:\C_cache\py\day18_WenJianChuLi\venv\Scripts\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # 2147483647 # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 5、sys.path # # # 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值 # ------------------------------------------------------------ ''' # # import sys # print(sys.path) # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # ['D:\\C_cache\\py\\day22_os_json_re_etc_MoKuai', 'D:\\C_cache\\py\\day22_os_json_re_etc_MoKuai', 'D:\\Anaconda3\\python36.zip', 'D:\\Anaconda3\\DLLs', 'D:\\Anaconda3\\lib', 'D:\\Anaconda3', 'D:\\Anaconda3\\lib\\site-packages', 'D:\\Anaconda3\\lib\\site-packages\\win32', 'D:\\Anaconda3\\lib\\site-packages\\win32\\lib', 'D:\\Anaconda3\\lib\\site-packages\\Pythonwin', 'D:\\Program Files (x86)\\PyCharm 2018.1.3\\helpers\\pycharm_matplotlib_backend'] # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 6、sys.platform # # # 返回操作系统平台名称 # # # ==>>>应用场景:当程序拷贝到其他的电脑的时候,需要进行对电脑的运行环境进行获取, # # # 以保证程序在其他的操作系统环境下能够正常的运行 # ------------------------------------------------------------ ''' # # import sys # print(sys.platform) # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # win32 # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 7、sys实例:进度条 # ------------------------------------------------------------ ''' # # 方式一: # import sys,time # i = 0 # while i<100: # sys.stdout.write(">") # sys.stdout.flush() # i +=1 # time.sleep(0.02) # print("\n完成传输!") # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # 完成传输! # # # # Process finished with exit code 0 # # 方式二: # import sys,time # for i in range(100): # sys.stdout.write(">") # sys.stdout.flush() # time.sleep(0.02) # print("\n完成传输!") # # # D:\Anaconda3\python.exe D:/C_cache/py/day22_os_json_re_etc_MoKuai/day22_2_os_json_re_etc_MoKuai.py # # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # 完成传输! # # # # Process finished with exit code 0
转载请注明出处。https://www.cnblogs.com/jyfootprint/p/9457346.html