This content originally appeared on DEV Community and was authored by Aya Bouchiha
Importing string module
import string
the most used python string module constants
digits
- digits: returns numbers from 0 to 9 as a string.
import string
print(string.digits) # 0123456789
print(type(string.digits)) # <class 'str'>
ascii_letters
- 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
- 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
- ascii_lowercase: returns all lowercase alphabet letters.
import string
# abcdefghijklmnopqrstuvwxyz
print(string.ascii_lowercase)
# 26
print(len(string.ascii_lowercase))
ponctuation
- punctuation: lets you get all punctuation symbols.
import string
# !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
print(string.punctuation)
# 32
print(len(string.punctuation))
# <class 'str'>
print(type(string.punctuation))
Summary
- 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.
Suggested Posts
To Contact Me:
email: developer.aya.b@gmail.com
telegram: Aya Bouchiha
Hope you enjoyed reading this post :)
This content originally appeared on DEV Community and was authored by Aya Bouchiha
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Aya Bouchiha | Sciencx (2021-08-11T23:03:23+00:00) The Most Used Python string Module Constants. Retrieved from https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/
" » The Most Used Python string Module Constants." Aya Bouchiha | Sciencx - Wednesday August 11, 2021, https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/
HARVARDAya Bouchiha | Sciencx Wednesday August 11, 2021 » The Most Used Python string Module Constants., viewed ,<https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/>
VANCOUVERAya Bouchiha | Sciencx - » The Most Used Python string Module Constants. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/
CHICAGO" » The Most Used Python string Module Constants." Aya Bouchiha | Sciencx - Accessed . https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/
IEEE" » The Most Used Python string Module Constants." Aya Bouchiha | Sciencx [Online]. Available: https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/. [Accessed: ]
rf:citation » The Most Used Python string Module Constants | Aya Bouchiha | Sciencx | https://www.scien.cx/2021/08/11/the-most-used-python-string-module-constants/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.