“Python encontre se a string contém espaço” Respostas de código

Python encontre se a string contém espaço

def space(text):
    if ' ' in text:
        return True
    else: return False
Shy Shrike

python se a string tiver espaços

In [1]: import re

In [2]: string = "Hello world"

In [3]: bool(re.search('\s', string))
Out[3]: True

In [4]: string = "World"

In [5]: bool(re.search('\s', string))
Out[5]: False
gdfelt

Como verificar se uma string contém espaços no python

#isspace() is a built-in method used for string handling
string = "My name is"
print(string.isspace())
#It will print True

string = "Hello"
print(string.isspace())
#It will print True
Grotesque Gazelle

Respostas semelhantes a “Python encontre se a string contém espaço”

Perguntas semelhantes a “Python encontre se a string contém espaço”

Mais respostas relacionadas para “Python encontre se a string contém espaço” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código