python 3.x - How to turn a string lists into a lists? -


there other threads turning strings inside lists different data types. want turn string in form of lists lists. this: "[5,1,4,1]" = [5,1,4,1]

i need because writing program requires user input lists

example of problem:

>>> x = input() [3,4,1,5] >>> x '[3,4,1,5]' >>> type(x) <class 'str'> 

if mean evaluate python objects this:

x = eval('[3,4,1,5]'); print (x); print(type(x) list)  [3, 4, 1, 5] true 

use caution can execute user input. better use parser native lists. use json input , parse it.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -