Python Standard Library based on Python 3.7.3 https://docs.python.org/3/library/
Python标准库 - 文本处理服务 - string库
Source code: Lib/string.py
Link: https://docs.python.org/3/library/string.html#module-string
目录链接:https://www.jianshu.com/p/e1e201bea601
字符串常量 String constants :
GitHub Code : String constants.py
string.ascii_letters 大小写字母常数
# ascii_letters 大小写字母常数
print(string.ascii_letters) # abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
string.ascii_lowercase 小写字母常数
# ascii_lowercase 小写字母常数
print(string.ascii_lowercase) # abcdefghijklmnopqrstuvwxyz
string.ascii_uppercase 大写字母常数
# ascii_uppercase 大写字母常数
print(string.ascii_uppercase) # ABCDEFGHIJKLMNOPQRSTUVWXYZ
string.digits 十进制数字常数
# digits 十进制数字常数
print(string.digits) # 0123456789
string.hexdigits 十六进制数字常数
# hexdigits 十六进制数字常数
print(string.hexdigits) # 0123456789abcdefABCDEF
string.octdigits 八进制数字常数
# octdigits 八进制数字常数
print(string.octdigits) # 01234567
string.punctuation ASCII字符串,在C语言环境中被视为标点字符
# punctuation ASCII字符串,在C语言环境中被视为标点字符
print(string.punctuation) # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
string.printable 能够被打印的ASCII字符串
# printable 能够被打印的ASCII字符串
print(string.printable)
# 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 还要加上 字符空间,制表符,换行符,返回页面,换页符和垂直选项卡
string.whitespace 字符空间,制表符,换行符,返回页面,换页符和垂直选项卡
# whitespace 包含所有被视为空格的ASCII字符的字符串
print(string.whitespace) # 字符空间,制表符,换行符,返回页面,换页符和垂直选项卡
自定义字符串格式 Custom String Formatting
GitHub Code :