,切割输入的字符串,当我发现我只输入字母时好像就不能切割了。例如 hello 切割成 h e l l o, split函数好像无法做到。
直接list('hello'),转成单字符列表
你可以使用Python中的字符串切片(slice)操作来实现将一个单词切割成单个字母,如下所示:
word = 'hello' letters = [c for c in word] print(letters)