随笔分类 - 标准库
摘要:import package1.Cat.Cat_Main #顶级目录.子目录.模块文件 #待完善
阅读全文
摘要:import sys print(sys.path) #获取模块文件搜索路径 sys.path[0]='E:\\python' #临时指定新的搜索路径 print(sys.path) print(sys.path[0]) #获取第一个搜索路径 print(sys.platform) #操作系统标识符
阅读全文
摘要:###os模块存放于Lib/os.py中 import os print(os.environ) #获取操作系统里设置的环境变量 print(os.getcwd()) #返回表示当前工作路径的字符串 print(os.system('ping 127.0.0.1')) #在子shell中执行命令(c
阅读全文
摘要:import random print(random.random()) #随机生成一个大于0小于1的数 print(random.uniform(-10,-1)) #在[-10,1)范围内获取一个随机浮点数 # 用random.triangular(low,high,mode)返回三角形分布的随机
阅读全文
摘要:math提供大量数学计算函数 import math print(math.trunc(3.9)) #3.9取整 3 price=3.23 print(math.ceil(price)) #对浮点数x取大整数 4 print(round(3.5)) #对3.5进行5入操作 4 print(round
阅读全文
摘要:#datetime实例的方法 from datetime import * print(datetime.now()) #返回当天的日期和时间 today=datetime.now() #定义today为当天日期时间对象 print(datetime.date(today)) #返回当天的日期对象
阅读全文
摘要:##内置对象 | 英文名称 | 中文名称|说明 | | | | | | Built-in Functions | 内置函数 |print()等 | | Built-in Constants | 内置常量 |False等 | | Built-in Types | 内置类型 | | | Built-in
阅读全文