1
for jr in json_reports:
  jr['time_created'] = str(jr['time_created'])
2
  • What don't you like about it? What's your concern? What do you think could be improved? Commented Jul 5, 2009 at 11:33
  • I thought there might be a one-liner, sort of like a list comprehension, but I geuss that doesn't apply here. Commented Jul 5, 2009 at 16:04

2 Answers 2

10

Looks to me that you're already there

Sign up to request clarification or add additional context in comments.

Comments

5

That would be the pythonic way to write the loop if you need to assign it to the same list.

If you just want to pull out strings of all time_created indices in each element of json_reports, you can use a list comprehension:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.