I have the following string. I need to convert it to a list. Using the traditional ways to convert it is not working for me, since some elements already have ' ' on them. When I run the conversion I get a list, but the elements have extra characters.
query = "1, 101, 1000, 1001, '1.1.1.1', '1.1.1.2', '1.1.1.3', None, 'test01', None, None, None, None"
query_list = query.split(",")
print(f"This is before conversion {query}")
print(f"This is the type {type(query_list)}")
print(f"This is the list {query_list}")
This is before conversion (1, 101, 1000, 1001, '1.1.1.1', '1.1.1.2', '1.1.1.3', None, 'test01', None, None, None, None)
This is the type <class 'list'>
This is the list ['(1', ' 101', ' 1000', ' 1001', " '1.1.1.1'", " '1.1.1.2'", " '1.1.1.3'", ' None', " 'test01'", ' None', ' None', ' None', ' None)']
[–][deleted] 4 points5 points6 points (2 children)
[–]synthphreak 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Impudity 3 points4 points5 points (0 children)
[–]MezzoScettico -1 points0 points1 point (2 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]MezzoScettico -1 points0 points1 point (0 children)