第一章:文本-文本常量和模板-常量

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文本越来越常见,这些常量的应用也变得很有限。
运行结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43193719/article/details/86654259