【发布时间】:2016-10-27 00:58:01
【问题描述】:
有没有办法在 python 中提取字符串中的每个子字符串?
例如,如果我有字符串
"Hello there my name is Python"
我想从该字符串中取出每个子字符串(或单个单词),以便从该字符串中取出"Hello", "there" , "my" , "name" , "is" 和"Python"?
【问题讨论】:
-
你至少应该搜索过。
str.split就是你想要的 -
a = "Hello there my name is Python"然后b = a.split()
标签: python string python-2.7