1.1.5 常量
string模块包括大量与ASCII和数值字符集相关的常量。
import inspect
import string
def is_str(value):
return isinstance(value,str)
for name,value in inspect.getmembers(string,is_str):
if name.startswith('_'):
continue
print('%s=%r\n' % (name,value))
这些常量在处理ASCII数据时很有用,不过由于采用某种Unicode的非ASCII文本越来越常见,这些常量的应用也变得很有限。
运行结果: