M.S.
string Module in Python
The constants defined in this module are:
1) string.ascii_letters
Syntax: string.ascii_letters
Return Type: String
Example:
import string
print(string.ascii_letters)
# Output:
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
2) string.ascii_lowercase
Syntax: string.ascii_lowercase
Return Type: String
Example:
import string
print(string.ascii_lowercase) # Output: 'abcdefghijklmnopqrstuvwxyz'
Page 1 of 5
M.S.
3) string.ascii_uppercase
Syntax: string.ascii_uppercase
Return Type: String
Example:
import string
print(string.ascii_uppercase)
# Output: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
4) [Link]
Syntax: [Link]
Return Type: String
Example:
import string
print([Link]) # Output: '0123456789'
5) [Link]
Syntax: [Link]
Return Type: String
Example:
import string
print([Link]) # Output: '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
6) [Link]
Syntax: [Link]
Page 2 of 5
M.S.
Return Type: String
Example:
import string
print([Link]) # Output: '0123456789abcdefABCDEF'
7) [Link](s)
Syntax: [Link](s)
Return Type: String
Example:
import string
s = "hello world"
result = [Link](s)
print(result) # Output: 'Hello World'
8) [Link]
Syntax: [Link]
Return Type: String
Example:
import string
print([Link]) # Output: ' \t\n\r\x0b\x0c'
9) [Link]
Syntax: [Link]
Return Type: String
Page 3 of 5
M.S.
Example:
import string
print([Link])
# Output:
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
TUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
10) [Link](substitute_string)
Syntax: [Link](substitute_string)
Return Type: Template object
Example:
import string
template = [Link]('$name is a $role.')
result = [Link](name='John', role='developer')
print(result) # Output: 'John is a developer.'
11) [Link]()
Syntax: [Link]()
Return Type: Formatter object
Example:
import string
formatter = [Link]()
result = [Link]('{} is a {}.', 'John', 'developer')
print(result) # Output: 'John is a developer.'
Page 4 of 5
M.S.
For more functions read following documentations:
[Link]
Page 5 of 5