如何判断是否可以拆分python(How to tell if something can be split python)
有没有什么方法可以判断是否可以在没有尝试和除块之外拆分某些东西? 让我们说我有这样的事情
stringOne = "Hello there how are you" stringTwo = ["hello","how","are","you"]
这是我尝试过的:
def fun(word): return "".join(["%s!" % x for x in word]) if len(word.split()) == 0 else "".join(word) fun(stringTwo)
那么任何方式来看看是否可以拆分某些东西? 像string.isdigit()或类似的东西?
Is there any way to tell if something can be split without a try and except block? Lets say I have something like this
stringOne = "Hello there how are you" stringTwo = ["hello","how","are","you"]
This is what I have tried:
def fun(word): return "".join(["%s!" % x for x in word]) if len(word.split()) == 0 else "".join(word) fun(stringTwo)
So any way to see if something can be split? like string.isdigit() or something similar?
原文:https://stackoverflow.com/questions/19579065
更新时间:2022-08-12 14:08