2005年11月07日 星期一 20:40
为什么这一段在py2.3中不能执行呢?有什么类似的办法可以这样生成字典哪? > 你也可以放弃一些简洁性来获得更高的威力。例如: > > 1 def dodict(*args, **kwds): > 2 d = {} > 3 for k, v in args: d[k] = v > 4 d.update(kwds) > 5 return d > 6 tada = dodict(*data.items( ), yellow=2, green=4) > > [译者:在python2.3中,tada = dodict(*data.items( ), yellow=2, green=4) > 不能执行。有一个语法错误] > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051107/28cc2f57/attachment.html
2005年11月07日 星期一 21:21
python-chinese,您好! 请问有没谁研究过PYTHON这个脚本语言的解释器源代码???? 谢谢. With Best Regard! 老K koria at 163.com 2005-11-07
2005年11月07日 星期一 21:30
在 05-11-7,zhang yunfeng<zhangyunfeng at gmail.com> 写道: > > > 为什么这一段在py2.3中不能执行呢?有什么类似的办法可以这样生成字典哪? > > > > 你也可以放弃一些简洁性来获得更高的威力。例如: > > > > 1 def dodict (*args, **kwds): > > 2 d = {} > > 3 for k, v in args : d[k] = v > > 4 d.update(kwds) > > 5 return d > > 6 tada = dodict(*data.items( ), yellow=2, green =4) > > > > > > > > [译者:在python2.3中,tada = dodict(*data.items( ), yellow=2, green=4) > 不能执行。有一个语法错误] > *data.items( )是什么东西? " * "是什么? > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > >
2005年11月07日 星期一 22:04
在05-11-7,Jason Liu <telecomliu at gmail.com> 写道: > > 在 05-11-7,zhang yunfeng<zhangyunfeng at gmail.com> 写道: > > > > > > 为什么这一段在py2.3中不能执行呢?有什么类似的办法可以这样生成字典哪? > > > > > > 你也可以放弃一些简洁性来获得更高的威力。例如: > > > > > > 1 def dodict > (*args, **kwds): > > > 2 d = {} > > > > 3 for k, v in args > : d[k] = v > > > > 4 d.update(kwds) > > > > 5 return d > > > 6 tada > = dodict(*data.items( > ), yellow=2, green > =4) > > > > > > > > > > > > [译者:在python2.3中,tada = dodict(*data.items( ), yellow=2, green=4) > > 不能执行。有一个语法错误] > > > > *data.items( )是什么东西? " * "是什么? data是之前定义的字典. 抱歉,忘记附上网址了 http://wiki.woodpecker.org.cn/moin/PyCkBk-1-3 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051107/2afe05c2/attachment.htm
2005年11月07日 星期一 22:25
在 05-11-7,zhang yunfeng<zhangyunfeng at gmail.com> 写道: > > > 在05-11-7,Jason Liu <telecomliu at gmail.com> 写道: > > 在 05-11-7,zhang yunfeng<zhangyunfeng at gmail.com> 写道: > > > > > > > > > 为什么这一段在py2.3中不能执行呢?有什么类似的办法可以这样生成字典哪? > > > > > > > > 你也可以放弃一些简洁性来获得更高的威力。例如: > > > > > > > > 1 def dodict > > (*args, **kwds): > > > > 2 d = {} > > > > > > 3 for k, v in args > > : d[k] = v > > > > > > 4 d.update(kwds) > > > > > > 5 return d > > > > 6 tada > > = dodict(*data.items ( > > ), yellow=2, green > > =4) > > > > > > > > > > > > > > > > [译者:在python2.3中,tada = dodict(*data.items( ), yellow=2, green=4) > > > 不能执行。有一个语法错误] > > > > > > > *data.items( )是什么东西? " * "是什么? > > data是之前定义的字典. > 抱歉,忘记附上网址了 http://wiki.woodpecker.org.cn/moin/PyCkBk-1-3 试了一下,好像只能用这种方式: tada = dodict( *data.items( ), **{ 'yellow' : 2, 'green' : 4 } )
2005年11月08日 星期二 10:56
> > tada = dodict( *data.items( ), **{ 'yellow' : 2, 'green' : 4 } ) > tada = dodict(yellow=2,green=4,*dota.items())
Zeuux © 2025
京ICP备05028076号