0

I have an array represented as a string.
Example: '[20,543,564,1234,67]'
How to convert this string into an array of integers in python3 as follows:-
[20,543,564,1234,67]

darshanc99
  • 139
  • 1
  • 8

1 Answers1

0
In [75]: import ast                                                                                                                                                                                                                                                                                                           

In [76]: s = '[20,543,564,1234,67]'                                                                                                                                                                                                                                                                                           

In [77]: ast.literal_eval(s)                                                                                                                                                                                                                                                                                                  
Out[77]: [20, 543, 564, 1234, 67]
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241