簡體   English   中英

用Python編寫此循環的方式是什么?

[英]What is the Pythonic way to write this loop?

for jr in json_reports:
  jr['time_created'] = str(jr['time_created'])

在我看來你已經在那兒了

如果需要將循環分配給相同的列表,那將是編寫循環的Python方法。

如果你只是想退出時,所有的字符串time_created指數中的每一個元素json_reports ,您可以使用列表理解:

strings = [str(i['time_created']) for i in json_reports]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM