'''
os模块
目录操作
.removedirs(dirname)
.makedirs(dirname)
.mkdir(dirname)
.rmdir(dirname)
.chdir(dirname)
.listdir(dirname)
属性
.environ
.name
.sep
.linesep
.pathsep
文件操作
.remove(file_name)
目录/文件操作
.rename(oldname,newname)
.stat()
获取
.getcwd()
.getpid()
.getppid()
.cpu_count()
命令
.system()
.popen().read()
os.path
对路径的操作
.abspath()
.split()
.basename()
.dirname()
.splitext()
判断
.isdir()
.isfile()
.exists()
.isabs()
获取
getctime
getmtime
getatime
getsize
合并路径
.join(os.path.abspath(), path)
sys模块
属性
.version
.platform
.path
.stdin
.stdout
.stderr
方法
sys.argv[]
sys.exit()
time模块
timestamp -->
format string
ctime
struct_time
localtime
gmtime
format string -->
struct_time
striptime
struct_time --> timestamp
mktime
format string
strftime
asctime
time.sleep
time.time
%Y %m %s %H %M %S
tm_year mon mday hours minutes seconds yday isdst
datetime模块
datetime(year, month, day, hours, minutes, seconds)
.now()
.today()
.utcnow()
date(year, month, day)
.today()
time(hours, minutes, seconds)
日期对象
.year() .month() .day() .weekday() .isoweekday()
timedelta对象
日期对象 + - 日期对象 = timedelta对象
日期对象 + - timedelta对象 = 日期对象
random模块
.random() 0-1
.randint(a, b)
.uniform(a, b)
.randrange(start, stop, step)
.choice([])
.sample([], int)
.shuffle(list)
math模块
.fabs()
.ceil()
.floor()
.pi
.pow(a, b)
sin()
cos()
tan()
json模块
dumps(obj)
loads(json)
dump(obj, file)
load(file)
pickle模块
dumps(obj)
loads(pickle)
dump(obj, file)
load(file)
collections模块
namedtuple()
a = namedtuple('a', '字段')
b = a(元组)
a.字段名
deque()
.append()
.pop()
.appendleft()
.popleft()
OrderedDict(**kwargs, [(k, v),...])
defaultdict(func, **kwargs, [(k, v),...])
Counter(iterable) {}
hashlib模块
hashlib.md5/sha1/sha224/sha256/sha384/(byte)
hexdigest()
configparser模块
对 ini 文件的操作
三板斧
a = configparser.ConfigParser()
a.read('.ini', encoding='')
a.write(open())
创建
a['section'] = {'option': 'value',...}
增加section
.add_section('section')
删除
.remove_section('section')
.remove_option('section', 'option')
修改option-value
.set('section', 'option', 'value')
查看
a['section']['option']
.sections()
.options('section')
.get('section', 'option')
getint
getfloat
getboolean
.items('section')
判断
has_section('section')
has_option('section', 'option')
struct模块
pack('', data)
unpack('', data)
CSV模块
a = writer(open)
.writerow([])
.writerows([[]])
.reader(open())
io模块
from io import StringIO, BytesIO
a = StringIO()
a.write('zhangzhuowei')
print(a.getvalue())
b = BytesIO()
b.write(b'zhangzhuowei')
print(b.getvalue())
'''