将python字符串“ ['a','b']”转换为列表

时间:2019-11-08 01:16:07

标签: python django python-3.x

我有一种将列表另存为字符串的表单,我想将这些字符串转换为列表,然后再保存到DB中。

我正在使用python3和Django。

字符串看起来像: '["MEX","MTY","GDL","BJX","QRO","PBC","TLC","CUN","EM","CUU"]'

最Python化的方式是什么?

1 个答案:

答案 0 :(得分:1)

import json

json.loads('["MEX","MTY","GDL","BJX","QRO","PBC","TLC","CUN","EM","CUU"]')