[問題] dict 取值

看板Python作者時間4年前 (2019/12/01 16:53), 4年前編輯推噓3(307)
留言10則, 3人參與, 4年前最新討論串1/1
http://i.imgur.com/xUTk3Ib.jpg
請問要怎麼把前面的dict value不要存取 我有試著存到另一個list 印出來還是有dictvalue http://i.imgur.com/oQoibeh.jpg
這是我的程式碼 我只想要存value內部的值而已 本來的架構是 {time stamp : 時間 , s_d0 :數值,s_h0:數值,s_t0:數值 } ----- Sent from JPTT on my OPPO CPH1701. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.138.51.78 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1575190397.A.ACB.html ※ 編輯: lucy35 (223.138.51.78 臺灣), 12/01/2019 16:55:28

12/01 16:59, 4年前 , 1F
for item in air: print(list(item.values()))
12/01 16:59, 1F

12/01 17:00, 4年前 , 2F
不過印出來應該不是你的目的 要看你要對這些value做什麼
12/01 17:00, 2F

12/01 17:00, 4年前 , 3F
不一定要是list才能操作
12/01 17:00, 3F
我想要把值存進mysql裡 ※ 編輯: lucy35 (223.138.51.78 臺灣), 12/01/2019 18:21:07

12/01 21:39, 4年前 , 4F
pandas 搭配 sqlalchemy
12/01 21:39, 4F

12/01 21:41, 4年前 , 5F
可以先用concat清洗dict
12/01 21:41, 5F

12/01 21:44, 4年前 , 6F
pd.dataframe.from_dict後 to_sql 就很方便了
12/01 21:44, 6F

12/01 21:54, 4年前 , 7F
更正一下 先把dict轉df後再用concat或merge清洗合併
12/01 21:54, 7F

12/08 21:53, 4年前 , 8F
for key,value in air.items():
12/08 21:53, 8F

12/08 21:53, 4年前 , 9F
list.append(value)
12/08 21:53, 9F

12/08 21:53, 4年前 , 10F
就可以了!
12/08 21:53, 10F
文章代碼(AID): #1TutzzhB (Python)