當前位置:首頁 » 存儲配置 » 字典存儲

字典存儲

發布時間: 2023-06-02 14:58:56

① 怎麼用python實現字典存儲為excel表格

這個字典不好看啊!
直接讀取value寫入csv文件,
import csv
f = open('file.csv','a',newline='')
w = writer(f)
w.writerow(dict(key))
打開csv文件另存為excel.
如果是很多個字典組成的列表,形式像[{a:1,b:2,c:3},……{a:4,b:5,c:6}],就可以用pandas來進行處理,存儲為excel, 表頭為a,b,c
dict_l = [{a:1,b:2,c:3},……{a:4,b:5,c:6}]
from pandas import DataFrame as DF
df = DF(dict_l)
df.to_csv(filename)

② python使用字典存儲學生的成績

student_id_list = [1, 2, 3, 4, 5....] # 學生id列表,可以是學號
score_list = [90, 91, 92, ...] # 對應的成績列表

result = dict(zip(student_id_list, score_list)) # result就是你想要的字典

熱點內容
hibernate對象緩存 發布:2025-09-14 22:25:37 瀏覽:869
crsa加密文件 發布:2025-09-14 22:14:19 瀏覽:96
linuxc語言程序設計 發布:2025-09-14 22:09:09 瀏覽:839
android可逆加密 發布:2025-09-14 22:07:17 瀏覽:356
沙迪克火花機鏡面編程 發布:2025-09-14 22:05:36 瀏覽:739
java流圖片 發布:2025-09-14 21:53:37 瀏覽:681
ae源碼 發布:2025-09-14 21:28:15 瀏覽:70
phpweb伺服器 發布:2025-09-14 21:22:01 瀏覽:772
ftp想再傳輸的文件怎麼獲取 發布:2025-09-14 20:44:43 瀏覽:917
sqlserver資料庫置疑 發布:2025-09-14 20:42:37 瀏覽:496