摘要: #update:合并两个字典,如果有交叉就覆盖更新,没有交叉的就创建 info={ 'stu1101':'Liu Guannan', 'stu1102':'Wang Ruipu', 'stu1103':'Sun Yanan' } b={'stu1101':'Liu Guannan', 1:3, 2:5 } info.update(b) print(inf... 阅读全文
posted @ 2018-01-04 18:10 耐烦不急 阅读(256) 评论(0) 推荐(0) 编辑
摘要: #key-value 字典无下标 所以乱序,key值尽量不要取中文 person_log={ '大二':{ 'Ya Nan':['free','cute','soso'], 'Sha sha':['微胖','白白的'] }, '大四':{ 'Guan Nan':['不错',"很大"] }, ... 阅读全文
posted @ 2018-01-04 18:09 耐烦不急 阅读(3917) 评论(0) 推荐(0) 编辑
摘要: #key-value 字典无下标 所以乱序,key值尽量不要取中文 info={ 'stu1101':'Liu Guannan', 'stu1102':'Wang Ruipu', 'stu1103':'Sun Yanan', } print(info) #查找 print(info['stu1101'])#精确查找,若没有则会出错,例如print(info['stu11... 阅读全文
posted @ 2018-01-04 18:08 耐烦不急 阅读(209) 评论(0) 推荐(0) 编辑
摘要: name="my name is 齐志光qizhiguang" print(name.capitalize())#首字母变大写 print(name.count('i'))#统计字母‘i’出现的次数 print(name.center(50,'-'))#一共打印50个字符,name放中间,不够的用‘-’补上 print(name.encode(encoding="utf-8"))#字符串编码成二... 阅读全文
posted @ 2018-01-04 16:21 耐烦不急 阅读(203) 评论(0) 推荐(0) 编辑