18
The Most Used Python string Module Constants
import string
- digits: returns numbers from 0 to 9 as a string.
import string
print(string.digits) # 0123456789
print(type(string.digits)) # <class 'str'>
- ascii_letters: lets you get all lowercase and uppercase alphabet letters.
import string
# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
print(string.ascii_letters)
# 52 (26 * 2)
print(len(string.ascii_letters))
- ascii_uppercase: helps you to get all uppercase alphabet letters.
import string
# ABCDEFGHIJKLMNOPQRSTUVWXYZ
print(string.ascii_uppercase)
# 26
print(len(string.ascii_uppercase))
- ascii_lowercase: returns all lowercase alphabet letters.
import string
# abcdefghijklmnopqrstuvwxyz
print(string.ascii_lowercase)
# 26
print(len(string.ascii_lowercase))
- punctuation: lets you get all punctuation symbols.
import string
# !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
print(string.punctuation)
# 32
print(len(string.punctuation))
# <class 'str'>
print(type(string.punctuation))
- digits: returns numbers from 0 to 9 as a string.
- ascii_letters: returns all lowercase and uppercase alphabet letters.
- ascii_uppercase: returns all uppercase alphabet letters.
- ascii_lowercase: returns all lowercase alphabet letters.
- ponctuaion: returns all punctuation symbols.
To Contact Me:
email: [email protected]
telegram: Aya Bouchiha
Hope you enjoyed reading this post :)
18