Murtaza Basu :
I am trying to convert a data read from an textfile to an array of numbers.
I have done the following,
with open(src+"process_ids.txt", "r") as f:
data = f.readlines()
the output data is,
['[36950, 36968, 36969]']
and the type is of string
I would like to convert it to an array of numbers such as,
[36950, 36968, 36969]
Ahmed :
It looks like it's a json format. You can try the following:
import json
with open(src+"process_ids.txt", "r") as f:
data = json.loads(f.read())
Now, data has a list type.
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=390451&siteId=1