String在python中拆分为单独的字符串

Jan*_*ake 2 python

我想要拆分"Onehundredthousand""one" "hundred" "thousand"使用python.我怎样才能做到这一点?

Byt*_*der 6

您可以使用字符串的partition方法将其拆分为3个部分(左侧部分,分隔符,右侧部分):

"onehundredthousand".partition("hundred")
# output: ('one', 'hundred', 'thousand')
Run Code Online (Sandbox Code Playgroud)


AKS*_*AKS 5

>>> s = "Onehundredthousand"
>>> s.replace('hundred', '_hundred_').split('_')
['One', 'hundred', 'thousand']
Run Code Online (Sandbox Code Playgroud)

这只适用于给定的字符串.