python-os模块

import os
# 当前py文件路径
branch_path = os.path.dirname(os.path.abspath(__file__))
print(branch_path) # D:uiautoyy
now = 20200913
reportfile = os.path.join(branch_path, '%sreport' % now)
print(reportfile) # D:uiautoyy20200913report
if not os.path.exists(reportfile):
os.mkdir(reportfile) # 不存在则创建
os.system('chcp 65001') # cmd输出中文乱码
os.environ.update({"__COMPAT_LAYER": "RUnAsInvoker"}) # 增加管理员权限打开
os.getcwd() # 获取当前路径
os.system("taskkill /f /im " + 'process_name') # 杀死进程
原文地址:https://www.cnblogs.com/12260420zxx/p/13663735.html