[英]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.