好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python函数-compile()

compile(source, filename, mode[, flags[, dont_inherit]])

代码示例:

>>> code = "for i in range(0, 10): print i"
>>> cmpcode = compile(code, '', 'exec')
>>> exec cmpcode
0
1
2
3
4
5
6
7
8
9
>>> str = "3 * 4 + 5"
>>> a = compile(str,'','eval')
>>> eval(a)
17 

查看更多关于python函数-compile()的详细内容...

  阅读:36次