python os模块

#_*_ encoding: utf-8 _*_   @author: ty  hery   2022/5/4

import sys
print(sys.path)   #打印环境变量
print(sys.argv)
print(sys.argv[2])
print("--------------------------01 aaaaaaaaaaaaaa-----------------------------------------------------------")
import os
# os.system ("dir")
cmd_res = os.system ("dir")     #  执行命令,不保存结果, 返回0,表示执行成功
print("-->" , cmd_res)
print("--------------------------02-----------------------------------------------------------")
cmd_res2 = os.popen("dir").read()
print("-->2" , cmd_res2)
os.mkdir("new_dir")
print("--------------------------03-----------------------------------------------------------")
posted @ 2022-05-04 11:15  ty1539  阅读(27)  评论(0编辑  收藏  举报