python_模块学习

'''
import sys
print(sys.path) #打印环境变量

#运行结果为:['D:\\PyCharm Community Edition 2018.2.2\\NewYear\\untitled1\\Python',
# 'D:\\PyCharm Community Edition 2018.2.2\\NewYear\\untitled1',
# 'D:\\Python\\python36.zip', 'D:\\Python\\DLLs',
# 'D:\\Python\\lib', ---标准库保存位置
# 'D:\\Python',
# 'D:\\Python\\lib\\site-packages'] ---第三方库保存位置

print(sys.argv) #打印相对路径
#打印结果:['D:\\PyCharm Community Edition 2018.2.2\\NewYear\\untitled1\\Python\\模块初识.py']
print(sys.argv[2]) #取出列表中第三个,计算机默认从0开始计数
'''

import os
#cmd_res = os.system("dir") #执行命令不保存结果
cmd_res1 = os.popen("dir").read()
#print(cmd_res)
print(cmd_res1)

#当前文件路径下创建目录
os.mkdir("new_dir1")

猜你喜欢

转载自www.cnblogs.com/monica001/p/10435186.html