Check if String Contains Only Numbers using Python

re.match function

import re

text = '0210426'
result = bool(re.match(r'^\d+$', text))

print(result)

Leave a Comment

Cancel reply

Your email address will not be published.