“Verifique se a string tem dígitos python” Respostas de código

teste python se número em string

>>> def hasNumbers(inputString):
...     return any(char.isdigit() for char in inputString)
... 
>>> hasNumbers("I own 1 dog")
True
>>> hasNumbers("I own no dog")
False
Thankful Turtle

Verifique se a string tem dígitos python

string = 'this string has digits 12345'
if any(char.isdigit() for char in string):
  #digits found
  print('"{}" has digits!'.format(string))
else:
  #digits NOT found
  print('"{}" does NOT have digits!'.format(string))
The God of Monkeys

Se qualquer número Python

def num_there(s):
    return any(i.isdigit() for i in s)
Dead Dog

Python Verifique se o número contém dígito

for number in numbers:
    if '4' in str(number):
        print('{} True'.format(number))
    else:
        print("False")
Victorious Vole

Como verificar se o dígito em int python

s = set(str(4059304593))
print('2' in s)
Tender Tapir

Respostas semelhantes a “Verifique se a string tem dígitos python”

Perguntas semelhantes a “Verifique se a string tem dígitos python”

Mais respostas relacionadas para “Verifique se a string tem dígitos python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código