之前测试不成功,用导入dis的方式。
但如何在命令行里加入 -m dis,就会OK啦。
python -m dis test.py
#coding: utf8x = [1, 2, 3]for i in x: print i
4 0 LOAD_CONST 0 (1) 3 LOAD_CONST 1 (2) 6 LOAD_CONST 2 (3) 9 BUILD_LIST 3 12 STORE_NAME 0 (x) 6 15 SETUP_LOOP 19 (to 37) 18 LOAD_NAME 0 (x) 21 GET_ITER >> 22 FOR_ITER 11 (to 36) 25 STORE_NAME 1 (i) 7 28 LOAD_NAME 1 (i) 31 PRINT_ITEM 32 PRINT_NEWLINE 33 JUMP_ABSOLUTE 22 >> 36 POP_BLOCK >> 37 LOAD_CONST 3 (None) 40 RETURN_VALUE