如何将字符串如a = "我是中国人"
,转换成列表li =["我","是","中","国","人"]
a = "我是一个中国人"
li = list(a)
print li
输出却是
['\xe6', '\x88', '\x91', '\xe6', '\x98', '\xaf', '\xe4', '\xb8', '\x80', '\xe4', '\xb8', '\xaa', '\xe4', '\xb8', '\xad', '\xe5', '\x9b', '\xbd', '\xe4', '\xba', '\xba']
我用JavaScript很简单的就实现了
var a = "我是中国人"
li = a.split("")
console.log(li) // >>>["我","是","中","国","人"]
不知道python应该如何实现?
可以先将字符串解编码成
unicode
, 再用list