Stack Overflow Asked on January 3, 2022
This looks easy. Maybe it is and I’m not seeing it. How would one turn the following string into a list in Python3?
"[(datetime.datetime(2020, 7, 24, 19, 6, 54), '1002', '3.1'), (datetime.datetime(2020, 7, 24, 19, 5, 10), '1001', '1.5')]"
I would like a list that looks identical to above without the double quotation marks.
This seems to be a legitimate python object:
a = "[(datetime.datetime(2020, 7, 24, 19, 6, 54), '1002', '3.1'), (datetime.datetime(2020, 7, 24, 19, 5, 10), '1001', '1.5')]"
import datetime
eval(a)
[(datetime.datetime(2020, 7, 24, 19, 6, 54), '1002', '3.1'), (datetime.datetime(2020, 7, 24, 19, 5, 10), '1001', '1.5')]
Answered by Onyambu on January 3, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP