Skip to content

Commit

Permalink
fix: 通过github更新数据
Browse files Browse the repository at this point in the history
  • Loading branch information
nichuanfang committed Nov 29, 2023
1 parent f141fee commit 978bfca
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions update_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import json
import requests

with open('data.json', mode='r+',encoding='utf-8') as my_file:
text = my_file.read()
data = json.loads(text)
# 新增数据
data.append({
'name': '新数据',
'age': 18
})
# 写入文件
with open('data.json', mode='w+',encoding='utf-8') as my_file:
my_file.write(json.dumps(data))
# with open('data.json', mode='r+',encoding='utf-8') as my_file:
# text = my_file.read()
# data = json.loads(text)
# # 新增数据
# data.append({
# 'name': '新数据',
# 'age': 18
# })
# # 写入文件
# with open('data.json', mode='w+',encoding='utf-8') as my_file:
# my_file.write(json.dumps(data))

print('已更新数据!')

0 comments on commit 978bfca

Please sign in to comment.