python eval的用法

 

>>>x = 7
>>> eval( '3 * x' )
21
>>> eval('pow(2,2)')
4
>>> eval('2 + 2')
4
>>> n=81
>>> eval("n + 4")
85


参考:
https://www.runoob.com/python/python-func-eval.html

 

posted @ 2019-06-27 23:38  anobscureretreat  阅读(178)  评论(0)    收藏  举报