Python论坛  - 讨论区

标题:Re: [python-chinese] exec open(filename)in results 这句是什么意思?

2006年01月20日 星期五 14:36

wangzhe wangzhe at eastcom.com
Fri Jan 20 14:36:55 HKT 2006

首先,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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号