📄 tokenize.py
字号:
# Tests for the 'tokenize' module.# Large bits stolen from test_grammar.py. # Comments"#"#'#"#\ # # abc'''##'''x = 1 ## Balancing continuationa = (3, 4, 5, 6)y = [3, 4, 5]z = {'a':5, 'b':6}x = (len(`y`) + 5*x - a[ 3 ] - x + len({ } ) )# Backslash means line continuation:x = 1 \+ 1# Backslash does not means continuation in comments :\x = 0# Ordinary integers0xff <> 2550377 <> 2552147483647 != 017777777777-2147483647-1 != 020000000000037777777777 != -10xffffffff != -1# Long integersx = 0Lx = 0lx = 0xffffffffffffffffLx = 0xfffffffffffffffflx = 077777777777777777Lx = 077777777777777777lx = 123456789012345678901234567890Lx = 123456789012345678901234567890l# Floating-point numbersx = 3.14x = 314.x = 0.314# XXX x = 000.314x = .314x = 3e14x = 3E14x = 3e-14x = 3e+14x = 3.e14x = .3e14x = 3.1e4# String literalsx = ''; y = "";x = '\''; y = "'";x = '"'; y = "\"";x = "doesn't \"shrink\" does it"y = 'doesn\'t "shrink" does it'x = "does \"shrink\" doesn't it"y = 'does "shrink" doesn\'t it'x = """The "quick"brown foxjumps overthe 'lazy' dog."""y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'y = '''The "quick"brown foxjumps overthe 'lazy' dog.''';y = "\n\The \"quick\"\n\brown fox\n\jumps over\n\the 'lazy' dog.\n\";y = '\n\The \"quick\"\n\brown fox\n\jumps over\n\the \'lazy\' dog.\n\';x = r'\\' + R'\\'x = r'\'' + ''y = r'''foo bar \\baz''' + R'''foo'''y = r"""foobar \\ baz""" + R'''spam'''# Indentationif 1: x = 2if 1: x = 2if 1: while 0: if 0: x = 2 x = 2if 0: if 2: while 0: if 1: x = 2# Operatorsdef d22(a, b, c=1, d=2): passdef d01v(a=1, *rest, **rest): pass(x, y) <> ({'a':1}, {'b':2})# comparisonif 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass# binaryx = 1 & 1x = 1 ^ 1x = 1 | 1# shiftx = 1 << 1 >> 1# additivex = 1 - 1 + 1 - 1 + 1# multiplicativex = 1 / 1 * 1 % 1# unaryx = ~1 ^ 1 & 1 | 1 & 1 ^ -1x = -1*1/1 + 1*1 - ---1*1# selectorimport sys, timex = sys.modules['time'].time()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -