# -*- coding: utf-8 -*-
import os
import sys
"""§ os"""
os.name # 返回当前操作系统内核。
# windows返回nt内核,linux返回posix内核。
os.environ # 返回当前环境变量,全部 <type 'dict'>。
os.getenv() # 获得环境变量 os.getenv("PYTHONPATH")。
os.listdir(path) # 列出path下所有目录和文件。
os.remove(file) # 删除文件。
os.mkdir/makedirs(file_path) # 创建目录/多层目录
os.path.exists(path) # 检测目录是否存在。
os.path.isabs() # 是否为绝对路径
os.path.isdir() # 是否为目录
os.path.isfile() # 是否为文件
os.path.join(path, name) # 连接路径和文件名
os.rename(old_name, new_name) # 重命名文件
os.system("""shell or CMD""") # 运行shell或者CMD命令。
os.getsize(file) # 获取文件大小,单位字节。
""" § sys """
sys.argv[0] # 第一个参数 python [xxx.py]
sys.exit(n) # 退出程序 正常退出exit(0)
sys.system() # 终端交互。
sys.popen() # 终端交互,并返回交互结果。
sys.path # 当前环境变量
sys.path.append("./") # 添加环境变量