摘要: 魔法方法 含义 基本的魔法方法 基本的魔法方法 有关属性 比较操作符 算数运算符 反运算 增量赋值运算 一元操作符 类型转换 上下文管理(with 语句) 容器类型 阅读全文
posted @ 2018-10-27 18:55 自由自在多快乐 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Python标准异常总结 阅读全文
posted @ 2018-10-27 18:52 自由自在多快乐 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 dict.clear()删除字典内所有元素 2 dict.copy()返回一个字典的浅复制 3 dict.fromkeys(seq[, val]) 创建一个新字典,以序列 seq 中元素做字典的键,val 为字典所有键对应的初始值 4 dict.get(key, default=None)返回指 阅读全文
posted @ 2018-10-27 18:52 自由自在多快乐 阅读(183) 评论(0) 推荐(0) 编辑
摘要: os模块中关于文件/目录常用的函数使用方法 函数名 使用方法 以下是支持路径操作中常用到的一些定义,支持所有平台 os.path模块中关于路径常用的函数使用方法 函数名 使用方法 以下为函数返回 True 或 False 阅读全文
posted @ 2018-10-27 18:51 自由自在多快乐 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 文件打开模式 文件对象方法 阅读全文
posted @ 2018-10-27 18:50 自由自在多快乐 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 集合类型内建方法总结 集合(s).方法名 等价符号 方法说明 以下方法仅适用于可变集合 阅读全文
posted @ 2018-10-27 18:47 自由自在多快乐 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 字符串的方法及注释 阅读全文
posted @ 2018-10-27 18:43 自由自在多快乐 阅读(196) 评论(0) 推荐(0) 编辑
摘要: >>> f = open("D:\\all.txt", "r")>>> f.read()Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> f.read()UnicodeDecodeError: 'gb 阅读全文
posted @ 2018-10-27 18:41 自由自在多快乐 阅读(5616) 评论(0) 推荐(0) 编辑
摘要: asset_all = eval(input("请输入总资产:"))car_dict = {}# dict_list = {# "电脑":{"single_price":"单价","num":"个数"}## }goods = [ {"name":"电脑","price": 1999}, {"name 阅读全文
posted @ 2018-10-27 18:40 自由自在多快乐 阅读(187) 评论(0) 推荐(0) 编辑
摘要: asset_all = eval(input("请输入总资产:"))car_list = []goods = [ {"name":"电脑","price": 1999}, {"name":"鼠标","price": 10}, {"name":"游艇","price": 20}, {"name":"美 阅读全文
posted @ 2018-10-27 18:38 自由自在多快乐 阅读(129) 评论(0) 推荐(0) 编辑
摘要: dict = { "河北": { "石家庄":{"晋州市","平山县","元氏"}, "邯郸": {"永年","涉县","磁县"}, }, "河南": { "郑州": {"新郑","荥阳","新密"}, "周口": {"项城","淮阳","太康&qu 阅读全文
posted @ 2018-10-27 18:37 自由自在多快乐 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 1.字典 li = {"alex"," aric","Alex","Tony","rain"}for i,j in enumerate(li,1): new_j = j.strip() print(i,new_j) RESTART: C:/Users/wssar/AppData/Local/Prog 阅读全文
posted @ 2018-10-27 18:36 自由自在多快乐 阅读(876) 评论(0) 推荐(0) 编辑
摘要: li = ["alex"," aric","Alex","Tony","rain"]for i in li: new_li = i.strip() if (new_li.startswith('a') or new_li.startswith('A')) and new_li.endswith('c 阅读全文
posted @ 2018-10-27 18:34 自由自在多快乐 阅读(1151) 评论(0) 推荐(0) 编辑
摘要: li = [11,22,33,44,55,66,77,88,99]dict = {'k1':[],'k2':[]}for i in li: if i < 66: dict["k1"].append(i) else: dict['k2'].append(i)print(dict) 阅读全文
posted @ 2018-10-27 18:33 自由自在多快乐 阅读(406) 评论(0) 推荐(0) 编辑
摘要: s1 = "李露"l1 = list(s1)print(l1) s2 = ("alex","laonanhai","seven")l2 = list(s2)print(l2) s3 = {"k1":"alex", "k2":"seven"}l3 = list(s3.items())print(l3) 阅读全文
posted @ 2018-10-27 18:31 自由自在多快乐 阅读(239) 评论(0) 推荐(0) 编辑
摘要: x = str() #创建字符串#转换成字符串,字节,编码 m = bytes()#创建字节#转换成字节,字符串,要编程什么编码类型的字节 a = "李露" b1 = bytes(a, encoding='utf-8')print(b1)b2 = bytes(a, encoding='gbk')pr 阅读全文
posted @ 2018-10-27 18:29 自由自在多快乐 阅读(154) 评论(0) 推荐(0) 编辑
摘要: # enumerate 自动生成一列, 默认0开始,每次自增+1li = ["电脑","鼠标垫","U盘","游艇"]for key, item in enumerate(li, 1): print(key,item) inp = input("请输入商品:")# 字符串转换成intinp_num 阅读全文
posted @ 2018-10-27 18:28 自由自在多快乐 阅读(169) 评论(0) 推荐(0) 编辑
摘要: name = 0while name < 3: user = input("请输入用户名:") psd = input("请输入密码:") if user == "wss" and psd == "123": print("登陆成功") break else: print("请重新输入") name 阅读全文
posted @ 2018-10-27 18:22 自由自在多快乐 阅读(161) 评论(0) 推荐(0) 编辑