Show Menu
Cheatography

Python string module Cheat Sheet (DRAFT) by

When dealing with strings in python, there is a very helpful standard module : string.py. String module contains some constants, utility function, and classes for string manipulation.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Constants : ascii_­letters

import string

all_letters = string.ascii_letters

print(all_letters)
output :
abcdef­ghi­jkl­mno­pqr­stu­vwx­yzA­BCD­EFG­HIJ­KLM­NOP­QRS­TUVWXYZ

Constants : ascii_­low­ercase OR ascii_­upp­ercase

import string

lower_letters = string.ascii_lowercase
upper_letter = string.ascii_uppercase

print (lower_letters, upper_letter, sep = "\n")
Output :
abcdef­ghi­jkl­mno­pqr­stu­vwxyz
ABCDEF­GHI­JKL­MNO­PQR­STU­VWXYZ