为什么我总是得到 YES!!!
?如果字符串包含空格(换行符、点击、空格),我需要返回 NO!!!
user = "B B"
if user.isspace():
print("NO!!!")
else:
print("YES!!!")
最佳答案
def tt(w):
if ' ' in w:
print 'space'
else:
print 'no space'
>> tt('b ')
>> space
>> tt('b b')
>> space
>> tt('bb')
>> no space
我在火车上,很抱歉没有解释..不能输入太多..
关于python - 检查字符串中的空格(python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26987222/