一、模块概述:
1.os模块:
import os # print(os.getcwd()) # # os.chdir('哦哦哦') # print(os.getcwd()) # os.chdir('.') # print(os.getcwd()) # os.chdir('..') # print(os.getcwd()) # os.makedirs('test1/test2/test3') # os.chdir('..') # print(os.getcwd()) # os.removedirs('os模块/test1/test2/test3') # os.chdir('.') # print(os.getcwd()) # os.removedirs('test1/test2/test3') # print(os.system('ipconfig')) print(os.environ)
2.time模块:
import time # 结构化时间与时间戳的简单介绍: # print(time.time()) # t=time.localtime() # print(time.localtime()) # print(t.tm_year) # print(time.localtime(time.time())) # # 结构化时间转化为时间戳 # print(time.mktime(time.localtime())) # # 将结构化时间转化为字符串时间: # print(time.strftime('%Y-%m-%d %X',time.localtime())) # # # 将字符串时间转化为结构化时间: # print(time.strptime('2018:12:12:17:50:36','%Y:%m:%d:%X')) # # # 转化为系统定的时间格式: # print(time.ctime()) # print(time.asctime()) # import datetime # print(datetime.datetime.now()) # import time # import sys # print(sys.path) # print(time.ctime())
二、包的调用,包的调用路径、验证__name__的重要作用三部分内容见源码包
三、random函数:
import random # print(random.random()) # print(random.randint(1,3)) # print(random.randrange(1,3)) # print(random.shuffle([1,2,3,4,5])) #返回None ret=[1,2,3,4,5] random.shuffle(ret) print(ret)