在Python中将字符串转换为Dict或List?
是否将此字符串转换为python中的列表或字典在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',
['[', '{', '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'>