Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中将字符串拆分为字符?_Python_String_List_Character - Fatal编程技术网

如何在python中将字符串拆分为字符?

如何在python中将字符串拆分为字符?,python,string,list,character,Python,String,List,Character,我知道: print(list('Hello')) 将打印 ['H', 'e', 'l', 'l', 'o'] ['Hello', 'world!'] 我知道这一点 print(list('Hello world!')) 将打印 ['H', 'e', 'l', 'l', 'o'] ['Hello', 'world!'] 最容易获得的语法是: ['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!'] 列出“你好,世界!”

我知道:

print(list('Hello'))
将打印

['H', 'e', 'l', 'l', 'o']
['Hello', 'world!']
我知道这一点

print(list('Hello world!'))
将打印

['H', 'e', 'l', 'l', 'o']
['Hello', 'world!']
最容易获得的语法是:

['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']
列出“你好,世界!”给你想要的,而不是“你好”,“世界!”

我认为您混淆了以下内容的输出:

在Python3.6下工作

 a = "Hello world!"
 listresp = list(map(list, a))
 listff =[]
 print (listresp)
 for charersp in listresp:
     for charfinnal in charersp:
         listff.append(charfinnal)
 print (listff)


 ['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']