Python convert list string to list

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python convert list string to list相关的知识,希望对你有一定的参考价值。

http://stackoverflow.com/questions/1894269/convert-string-representation-of-list-to-list-in-python

 

>>> import ast
>>> x = u‘[ "A","B","C" , " D"]‘
>>> x = ast.literal_eval(x)
>>> x
[‘A‘, ‘B‘, ‘C‘, ‘ D‘]
>>> x = [n.strip() for n in x]
>>> x
[‘A‘, ‘B‘, ‘C‘, ‘D‘]

以上是关于Python convert list string to list的主要内容,如果未能解决你的问题,请参考以下文章

Convert Sorted Array to Binary Search Tree & Convert Sorted List to Binary Search Tree

leetcode 109 Convert Sorted List to Binary Search Tree

如何把16进制编码转换为中文

Convert Sorted List to Balanced BST

Convert a given Binary Tree to Doubly Linked List

Java 8 – Convert List to Map