"""Constants and membership tests for ASCII characters"""NUL = 0x00 # ^@SOH = 0x01 # ^ASTX = 0x02 # ^BETX = 0x03 # ^CEOT = 0x04 # ^DENQ = 0x05 # ^EACK = 0x06 # ^FBEL = 0x07 # ^GBS = 0x08 # ^HTAB = 0x09 # ^IHT = 0x09 # ^ILF = 0x0a # ^JNL = 0x0a # ^JVT = 0x0b # ^KFF = 0x0c # ^LCR = 0x0d # ^MSO = 0x0e # ^NSI = 0x0f # ^ODLE = 0x10 # ^PDC1 = 0x11 # ^QDC2 = 0x12 # ^RDC3 = 0x13 # ^SDC4 = 0x14 # ^TNAK = 0x15 # ^USYN = 0x16 # ^VETB = 0x17 # ^WCAN = 0x18 # ^XEM = 0x19 # ^YSUB = 0x1a # ^ZESC = 0x1b # ^[FS = 0x1c # ^\GS = 0x1d # ^]RS = 0x1e # ^^US = 0x1f # ^_SP = 0x20 # spaceDEL = 0x7f # deletecontrolnames = ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL","BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI","DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB","CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US","SP"]def _ctoi(c):if type(c) == type(""):return ord(c)else:return cdef isalnum(c): return isalpha(c) or isdigit(c)def isalpha(c): return isupper(c) or islower(c)def isascii(c): return 0 <= _ctoi(c) <= 127 # ?def isblank(c): return _ctoi(c) in (9, 32)def iscntrl(c): return 0 <= _ctoi(c) <= 31 or _ctoi(c) == 127def isdigit(c): return 48 <= _ctoi(c) <= 57def isgraph(c): return 33 <= _ctoi(c) <= 126def islower(c): return 97 <= _ctoi(c) <= 122def isprint(c): return 32 <= _ctoi(c) <= 126def ispunct(c): return isgraph(c) and not isalnum(c)def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32)def isupper(c): return 65 <= _ctoi(c) <= 90def isxdigit(c): return isdigit(c) or \(65 <= _ctoi(c) <= 70) or (97 <= _ctoi(c) <= 102)def isctrl(c): return 0 <= _ctoi(c) < 32def ismeta(c): return _ctoi(c) > 127def ascii(c):if type(c) == type(""):return chr(_ctoi(c) & 0x7f)else:return _ctoi(c) & 0x7fdef ctrl(c):if type(c) == type(""):return chr(_ctoi(c) & 0x1f)else:return _ctoi(c) & 0x1fdef alt(c):if type(c) == type(""):return chr(_ctoi(c) | 0x80)else:return _ctoi(c) | 0x80def unctrl(c):bits = _ctoi(c)if bits == 0x7f:rep = "^?"elif isprint(bits & 0x7f):rep = chr(bits & 0x7f)else:rep = "^" + chr(((bits & 0x7f) | 0x20) + 0x20)if bits & 0x80:return "!" + repreturn rep
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。