2006年01月20日 星期五 14:36
首先,exec "python语句" in 名字空间(子典)
例子是:b = {}
exec "a = 6" in b
这样b中就有{a:6}
exec open(filename) in results
作用就是执行filename文件,将文件中的变量导入results
同意Limodou
======= 2006-01-20 14:22:29 您在来信中写道:=======
>来自Using Mix-ins with Python的Listing 5:
>(http://www.linuxjournal.com/articles/lj/0084/4540/4540l5.html)
>
>results = {}
>exec open(filename) in results
>
>执行后results会被填值。有人能解释一下这里的 in 是怎么用的吗
>_______________________________________________
>python-chinese
>Post: send python-chinese at lists.python.cn
>Subscribe: send subscribe to python-chinese-request at lists.python.cn
>Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
= = = = = = = = = = = = = = = = = = = =
致
礼!
wangzhe
wangzhe at eastcom.com
2006-01-20
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wangzhe.vcf
Type: text/x-vcard
Size: 304 bytes
Desc: not available
Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20060120/f0267eb6/wangzhe.vcf
Zeuux © 2025
京ICP备05028076号