随笔分类 -  python-内置模块

摘要:import random # randint(a,b) 用来生成 [a,b]的随机整数 # print(random.randint(2,9)) # 生成0-1 的随机浮点数 # print(random.random()) # 生成a-b 的随机整数 2-8 # print(random.ran 阅读全文
posted @ 2025-01-02 14:23 13522679763-任国强 阅读(17) 评论(0) 推荐(0)
摘要:# math 数学计算 import math # # 计算阶乘 # print(math.factorial(6)) # 向下取整 12 # print(math.floor(12.98)) # 向上取整 15 # print(math.floor(15.01)) # 幂运算 8.0 2*2*2 阅读全文
posted @ 2024-12-31 17:21 13522679763-任国强 阅读(21) 评论(0) 推荐(0)
摘要:# sys 系统相关的功能 import sys from pprint import pprint print("hello world") # 程序退出 # sys.exit() # 查找模块的路径 # pprint(sys.path) # 可以像 input() 一样,从标准输入中读取数据 # 阅读全文
posted @ 2024-12-31 16:30 13522679763-任国强 阅读(20) 评论(0) 推荐(0)
摘要:import time t = time.time() # 时间戳 1970年 1735540726.765775 print(t) t = time.localtime() # 结构化的时间 time.struct_time(tm_year=2024, tm_mon=12, tm_mday=30, 阅读全文
posted @ 2024-12-31 16:07 13522679763-任国强 阅读(15) 评论(0) 推荐(0)
摘要:import os # 获取系统名字 nt # print(os.name) # # 路径分隔符 windows \ 非 windows / # print(os.sep) # abspath 获取文件的 绝对路径 # print(os.path.abspath('./')) # # 是否为文件夹 阅读全文
posted @ 2024-12-31 16:04 13522679763-任国强 阅读(28) 评论(0) 推荐(0)