风-fmgao

导航

2018年5月16日

省市县_me

摘要: # question 11import astfrom functools import reducedef file_read(): with open('D:\\pytharm\\jichuyufa\\day2\\pro_cty_con.txt', 'r', encoding='utf8') a 阅读全文

posted @ 2018-05-16 17:22 风-fmgao 阅读(82) 评论(0) 推荐(0) 编辑

python读取文件中的字典

摘要: import astdef file_read(): with open('D:\\pytharm\\jichuyufa\\day2\\pro_cty_con.txt', 'r', encoding='utf8') as f: san_dic = ast.literal_eval(f.read()) 阅读全文

posted @ 2018-05-16 14:24 风-fmgao 阅读(1764) 评论(0) 推荐(0) 编辑

省市县

摘要: #!/usr/bin/python3# -*- coding: utf-8 -*-# @Time : 2018/5/16 10:43# @File : shengshi.pydic = { "河北":{ "石家庄" :["鹿泉","藁城","元氏"], "邯郸" : ["永年","涉县","磁县"] 阅读全文

posted @ 2018-05-16 11:22 风-fmgao 阅读(164) 评论(0) 推荐(0) 编辑

布尔值运算&集合

摘要: 示例:返回booleanli = [] li = {} li = () if not li: print(1) radiansdict.has_key(key) #如果键在字典dict里返回true,否则返回false 示例所有的数据类型都自带布尔值,数据只有在0,None和空的时候为Falsepr 阅读全文

posted @ 2018-05-16 10:33 风-fmgao 阅读(872) 评论(0) 推荐(0) 编辑

商品列表,添加,显示

摘要: def file_read(): with open('D:\\pytharm\\jichuyufa\\day2\\shop.txt', 'r', encoding='utf8') as f: for i1 in f.readlines(): li1 = i1.split(',') print(li 阅读全文

posted @ 2018-05-16 10:07 风-fmgao 阅读(321) 评论(0) 推荐(0) 编辑

python 文件读写模式r,r+,w,w+,a,a+的区别(附代码示例)

摘要: 模式 可做操作 若文件不存在 是否覆盖r 只能读 报错 -r+ 可读可写 报错 是w 只能写 创建 是w+ 可读可写 创建 是a 只能写 创建 否,追加写a+ 可读可写 创建 否,追加写1.只读模式(r)一个存在的文件:def file_operation(): with open('/wzd/te 阅读全文

posted @ 2018-05-16 09:52 风-fmgao 阅读(2030) 评论(0) 推荐(0) 编辑