开发者社区> 问答> 正文

python必备内置函数-complie()  

python必备内置函数-complie()

展开
收起
请回答1024 2020-03-30 11:17:07 446 0
1 条回答
写回答
取消 提交回答
  • 将字符串编译成python 能识别或可以执行的代码,也可以将文字读成字符串再编译。

    In [74]: s  = "print('helloworld')"
    
    In [75]: r = compile(s,"<string>", "exec")
    
    In [76]: r
    Out[76]: <code object <module> at 0x0000000005DE75D0, file "<string>", line 1>
    
    In [77]: exec(r)
    helloworld
    
    2020-03-30 11:17:19
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载