摘要: 遍历一个文件夹下所有文件(文件夹可以嵌套) import os basepath = './' def get_file_from_path(path): if os.path.isdir(path): # 处理这个文件夹 for item in os.listdir(path): next_pat 阅读全文
posted @ 2020-06-16 20:38 Ryan_W 阅读(342) 评论(0) 推荐(0) 编辑
摘要: 列表 创建 list1 = ['physics', 'chemistry', 1997, 2000] 遍历 for x in list1: print(x) 访问特定元素 list1[0] # 'physics' list1[-1] # 2000 list1[1:2] # ['chemistry'] 阅读全文
posted @ 2020-06-16 20:13 Ryan_W 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 基本数据类型 整数int 浮点数float 字符串str 布尔值bool True False 可以用type()来判断变量类型。 字符串与其他的转换 字符串转整数 int('8') 整数转字符串 str(8) 整数与浮点 print(int(1.8)) #抹掉小数部分,保留整数部分 print(8 阅读全文
posted @ 2020-06-16 20:01 Ryan_W 阅读(136) 评论(0) 推荐(0) 编辑