Question:
Question:x = '[ "A","B","C" , " D"]'
x = ["A", "B", "C", "D"]
Question:
Question:
import ast x = '[ "A","B","C" , " D"]' x = ast.literal_eval(x)
Question:
x = [n.strip() for n in x]
如何將類似於下面這樣的列表字串表示轉換為列表?
['A', 'B', 'C', 'D']
以上是如何輕鬆地將列表的字串表示形式轉換為 Python 列表?的詳細內容。更多資訊請關注PHP中文網其他相關文章!