Check if space is in a string

前端 未结 5 2275
执笔经年
执笔经年 2021-02-11 14:08
\' \' in word == True

I\'m writing a program that checks whether the string is a single word. Why doesn\'t this work and is there any better way to che

5条回答
  •  Happy的楠姐
    2021-02-11 14:54

    You can try this, and if it will find any space it will return the position where the first space is.

    if mystring.find(' ') != -1:
        print True
    else:
        print False
    

提交回复
热议问题