Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.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中将字符串转换为Dict或List?_Python_List_Dictionary - Fatal编程技术网

在Python中将字符串转换为Dict或List?

在Python中将字符串转换为Dict或List?,python,list,dictionary,Python,List,Dictionary,是否将此字符串转换为python中的列表或字典 ['[', '{', 'u', "'", 'f', 'i', 'r', 's', 't', '_', 'n', 'a', 'm', 'e', "'", ':', ' ', 'u', "'", 'j', 'o', 'h', 'n', "'", ',', ' ', 'u', "'", 'l', 'a', 's', 't', '_', 'n', 'a', 'm', 'e', "'", ':', ' ', 'u', "'", 's', 'm', 'i',

是否将此字符串转换为python中的列表或字典

['[', '{', 'u', "'", 'f', 'i', 'r', 's', 't', '_', 'n', 'a', 'm', 'e', "'", ':', ' ', 'u', "'", 'j', 'o', 'h', 'n', "'", ',', ' ', 'u', "'", 'l', 'a', 's', 't', '_', 'n', 'a', 'm', 'e', "'", ':', ' ', 'u', "'", 's', 'm', 'i', 't', 'h', "'", ',', ' ', 'u', "'", 'a', 'g', 'e', "'", ':', ' ', '2', '0', ',', ' ', 'u', "'", 'm', 'o', 'b', 'n', 'u', 'm', "'", ':', ' ', 'u', "'", '1', '2', '3', '4', '1', '9', '0', '8', "'", ',', ' ', 'u', "'", '_', 'i', 'd', "'", ':', ' ', '1', ',', ' ', 'u', "'", 'e', 'm', 'a', 'i', 'l', "'", ':', ' ', 'u', "'", 's', 'm', 'i', 't', 'h', '@', 'g', 'm', 'a', 'i', 'l', '.', 'c', 'o', 'm', "'", '}', ']']

你是怎么做到的?

它本身就是一个列表,你说要把它转换成列表!通过将给定代码指定为,尝试打印typea!!然后你会得到

<type 'list'>

作为输出

你是说字符['['、'{'、''u'、'..存储在Python字符串中?需要什么输出?它应该是[{名字:john,姓氏:smith,年龄:20…}]@Janardhan:你拥有的是字符列表,而不是字符串。
<type 'list'>