os模块
import os
# 获取当前工作目录,即当前python脚本工作的目录路径
os.getcwd()
# 改变当前脚本的工作目录, 相当于shell下的cd
os.chdir('dir')
# 生成单级目录,相当于shell下的mkdir dir
os.mkdir('dir')
# 删除单级目录,相当于shell下的rmdir dir
os.rmdir('dir')
# 删除文件
os.remove()
# 输出字符串指示当前使用的平台, Windows下为 'nt', Linux下为'posix'
os.name
# 显示系统环境变量
os.environ
# 运行shell命令,直接显示
os.system('cmd')
# 返回path规范化的绝对路径
os.path.abspath(path)
# 将path分割成目录和文件名二元组返回
os.path.split(path)
# 如果path存在,返回True; 如果path不存在, 返回FALSE
os.path.exists(path)
sys模块
import sys
# 加入搜索包的路径
sys.path.append('dir_path')
# 退出程序
sys.exit(n)
# 查询Python解释器的版本
sys.version
# 返回模块的搜索路径
sys.path
# 返回操作系统的名称 windwos下返回 win32字符串
sys.platform
time模块
import time
# 时间戳 1970年1月1日之后的秒
time.time()
# 格式化后的时间 2020-09-23
time.strftime('%Y-%m-%d')
# 结构化元组时间 time.struct_time(tm_year=2020, tm_mon=9, tm_mday=22, tm_min-34, tm_sec=10, tm_wday=1, tm_yday=266, tm_isdst=1)
time.localtime()
datetime模块
import datetime
# 输出当前标准时间 eg: 2019-01-07 16:44:57.614705
datetime.datetime.now()
logging模块
import logging
logging.debug('debug message')
logging.info('info message')
logging.warning('warning message')
logging.error('error message')
logging.critical('critical message')
warnings模块
import warnings
warnings.filterwarnings('ignore')