Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将userinput声明为列表的信息_Python_String_List - Fatal编程技术网

Python 如何将userinput声明为列表的信息

Python 如何将userinput声明为列表的信息,python,string,list,Python,String,List,我正在制作我自己的编码-解码程序,为了解码,我必须将用户的输入作为输入 我尝试了join和list方法,但它们对我不起作用 c = input() list(c) 我希望当我输入我得到编码的列表时,例如:[14452356271432]在代码中,c=[14552,…]您可以使用ast.literal\u eval() 输入: [123,456,789] 然后: 打印(c) #[123, 456, 789] 印刷品(c类) # 你能分享一下在input()中输入的样本值看起来是什么样的吗sec

我正在制作我自己的编码-解码程序,为了解码,我必须将用户的输入作为输入

我尝试了join和list方法,但它们对我不起作用

c = input()
list(c)

我希望当我输入我得到编码的列表时,例如:
[14452356271432]
在代码中,
c=[14552,…]
您可以使用
ast.literal\u eval()

输入:

[123,456,789]
然后:

打印(c)
#[123, 456, 789]
印刷品(c类)
#

你能分享一下在
input()中输入的样本值看起来是什么样的吗sec@DeveshKumarSingh['22099','29819','11168','11168','93220']您是否在寻找一种方法来验证
c
是否包含一个列表?@ScottHunter no我想要c=作为列表的输入
[123,456,789]
print(c)
#[123, 456, 789]
print(type(c))
#<class 'list'>