1 JSON 内置库
适用内置库实现 json 的基本操作
import json
food_ratings = {"organic dog food": 2, "human food": 10}
json.dumps(food_ratings) # 将 Python 字典转换为 JSON 对象
# '{"organic dog food": 2, "human foo
分类目录归档:Python数据读取
适用内置库实现 json 的基本操作
import json
food_ratings = {"organic dog food": 2, "human food": 10}
json.dumps(food_ratings) # 将 Python 字典转换为 JSON 对象
# '{"organic dog food": 2, "human foo
sqlite3是一种文件数据库,Python内置了sqlite3驱动:
import sqlite3
# 数据库连接
con = sqlite3.connect('mydata.sqlite')
# 执行sql-建表语句
query = "CREATE TABLE test (a VARCHAR(20), b VARCHAR(20), c REAL, d INTEGER);"
con.execute(query)
con.co