摘要: 1 """写入csv文件""" 2 3 4 import csv 5 6 # 方法一: 7 def write_csv_demo1(): 8 headers = ['username', 'age', 'height'] 9 values = [ 10 ('张三', 18, 180), 11 ('李 阅读全文
posted @ 2020-06-15 22:22 udbful 阅读(209) 评论(0) 推荐(0)
摘要: 1 """读取csv文件""" 2 3 4 import csv 5 6 def readcsv_demo1(): 7 """采用列表形式,下标操作""" 8 with open('csvwriter.csv', 'r') as fp: 9 # reader是一个迭代器 10 reader = cs 阅读全文
posted @ 2020-06-15 22:14 udbful 阅读(229) 评论(0) 推荐(0)
摘要: 1 """json字符串到Python对象""" 2 3 4 import json 5 6 json_str = '[{"username": "张三", "age": 18, "country": "china"}, {"username": "lisi", "age": 20, "countr 阅读全文
posted @ 2020-06-15 22:01 udbful 阅读(744) 评论(0) 推荐(0)
摘要: 1 """ptyhon对象转json字符串""" 2 3 4 import json 5 6 persons = [ 7 {'username': '张三', 'age': 18, 'country': 'china'}, 8 {'username': 'lisi', 'age': 20, 'cou 阅读全文
posted @ 2020-06-15 21:59 udbful 阅读(112) 评论(0) 推荐(0)