上一页 1 ··· 4 5 6 7 8
摘要: 一. 文件读取 f = open("123456", mode = "r", encoding = "utf-8") "123456": 文件路径 1. 绝对路径 c:/abc/123.txt https://www.xxxxx.com/qwe.jpg 2.相对路径 ../../abc/def (用 阅读全文
posted @ 2018-08-06 19:25 NachoLau 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 一. set集合 空集合 a = set() set集合内的元素必须可哈希(不可变), int, str, bool, tuple set3 = {'1','alex',2,True,(1,2,[2,3,4])} 这会报错 set可去重, 用set(lst)去重. lst = list(set(ls 阅读全文
posted @ 2018-08-03 17:49 NachoLau 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 一. is和== is比较的是两个变量的内存地址. ==比较的是两个变量的值. is 小数据池: -5 ~ 256 在这个范围中的两个变量内存地址相同, print(a is b) 输出为True, 超出范围输出为False. 在pycharm中和终端中不一样, pycharm中, 超过256也输出 阅读全文
posted @ 2018-08-02 16:11 NachoLau 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 一. 字典 字典的键必须是不可变的, 是可哈希的, 可以用数字, 字符串, 元组, 布尔值, 不可用列表, 字典, 集合. 值可以取任何数据类型. 键必须是唯一的. 字典的元素是按照哈希表的顺序保存的, 而哈希表不是连续的, 字典不能切片, 只能通过键来获取. 二. 字典的操作: dic = {1: 阅读全文
posted @ 2018-08-01 11:03 NachoLau 阅读(574) 评论(0) 推荐(0) 编辑
摘要: 一. 列表列表内元素可增删改查 lst = ['手机', '电脑', '内存', '地板除', '次幂', ['Python', 'Java', 'C#']]切片 print(lst[2:5]) print(lst[-1]) print(lst[5][1][2]) print(lst[0:5:2])增 print(lst.append("English")) print(lst.in... 阅读全文
posted @ 2018-07-31 19:52 NachoLau 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 一. int类型 a = 123 print(a.bit_length()) # 7 二. float类型 a = 1 print("%.2f" % a) 三. bool类型 a = 0 a = '' 空字符串 a = [] a = {} a = tuple() a = set() a = None 阅读全文
posted @ 2018-07-30 21:07 NachoLau 阅读(162) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8