模块描述
A collection of string constants.
简要接口文档
__all__ = ["ascii_letters", "ascii_lowercase", "ascii_uppercase", "capwords",
"digits", "hexdigits", "octdigits", "printable", "punctuation",
"whitespace", "Formatter", "Template"]
模块全局变量
whitespace -- a string containing all ASCII whitespace
ascii_lowercase -- a string containing all ASCII lowercase letters
ascii_uppercase -- a string containing all ASCII uppercase letters
ascii_letters -- a string containing all ASCII letters
digits -- a string containing all ASCII decimal digits
hexdigits -- a string containing all ASCII hexadecimal digits
octdigits -- a string containing all ASCII octal digits
punctuation -- a string containing all ASCII punctuation characters
printable -- a string containing all ASCII characters considered printable
whitespace = ' \t\n\r\v\f'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable = digits + ascii_letters + punctuation + whitespace
模块函数
def capwords(s, sep=None): -->string
参数:
s --> 文本字符串
sep --> 分割依据,默认空格
返回值:
string --> 返回按分隔符分割后单词首字母大写后的字符串
模块类
class Template(metaclass=_TemplateMetaclass):
delimiter = '$' # 默认分隔符
idpattern = r'(?a:[_a-z][_a-z0-9]*)' # 默认匹配字符串
braceidpattern = None # 默认分割字符串
flags = _re.IGNORECASE # 默认字符格式
def __init__(self, template):
self.template = template
def substitute(*args, **kws):
return self.pattern.sub(convert, self.template)
def safe_substitute(*args, **kws):
return self.pattern.sub(convert, self.template)
class Formatter:
def format(*args, **kwargs):
return self.vformat(format_string, args, kwargs)
网友评论