#coding=utf-8
import sys, os, time, traceback, types
source = "#coding=utf-8/n/n"
source += "print 'hello world!' /n"
source += "print 'hello!' /n"
source += "print u'您好!' /n"
description = ""
mod = None
code = compile(source, description, "exec")
exec code #in mod
import sys, os, time, traceback, types
source = "#coding=utf-8/n/n"
source += "print 'hello world!' /n"
source += "print 'hello!' /n"
source += "print u'您好!' /n"
description = ""
mod = None
code = compile(source, description, "exec")
exec code #in mod
本文提供了一个简单的Python脚本示例,演示了如何通过编译和执行字符串形式的Python代码来打印问候语句。该过程涉及创建源代码字符串、设置描述符并使用Python内置的compile函数将源代码编译为可执行代码对象。
1241

被折叠的 条评论
为什么被折叠?



