python里怎么把中文字符串转化为成list?
比如我有string = '机器学习',我怎么可以得到
list_string = ['机', '器', '学', '习']?
2个回答
我一般是先decode再encode
>>> string = '机器学习'
>>> list_string = map(lambda x: x.encode('utf-8'), string.decode('utf-8'))
>>> for i in list_string:
print i
机
器
学
习
SofaSofa数据科学社区DS面试题库 DS面经
这个是python2吧,现在python3很方便啊
-
木子周
2019-05-15 11:31