I have a string:
s = "['9780310714675', '9780763630614', '9781416925330', '9780310714569']"
when loaded into memory, this becomes:
'[\'9780310714675\', \'9780763630614\', \'9781416925330\', \'9780310714569\']'
I wonder how to convert it to a list of strings:
strList = ['9780310714675', '9780763630614', '9781416925330', '9780310714569']
I have tried to do this using:
strList = json.loads(s)
but then I got the following error:
Traceback (most recent call last):
File "/home/xxx/dev/python/data-processing/MongoDB/query.py", line 101, in <module>
isbnList = marcQuery.stringToStringList(isbnString)
File "/home/xxx/dev/python/data-processing/MongoDB/query.py", line 74, in stringToStringList
strList = json.loads(s)
File "/home/xxx/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/home/xxx/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/xxx/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)
Can anyone give me some hints on how to do this?