2005年06月18日 星期六 18:23
在《python scripting for computational science》里看到的这样的用法,这是字 典还是? --- # data compiler_data['GNU']['type'] = 'GNU 3.0' compiler_data['GNU']['name'] = 'g77' compiler_data['GNU']['options'] = '-Wall' compiler_data['GNU']['libs'] = '-lf2c' compiler_data['GNU']['test'] = '-Wall' compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') for compiler in compiler_data: c = compiler_data[compiler] # 'GNU', 'Sun', etc. cmd = ' '.join([c['name'], c['options'], c['libs']]) for flag in c[flags]: os.system(' '.join([cmd, flag, ' -o app ', files]))
2005年06月18日 星期六 19:26
这是字典的用法呀。现在可以使用: for i in d: 这种用法来遍历字典d的键值。有兴趣你自已可以试一试。 在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: > 在《python scripting for computational science》里看到的这样的用法,这是字 > 典还是? > --- > # data > compiler_data['GNU']['type'] = 'GNU 3.0' > compiler_data['GNU']['name'] = 'g77' > compiler_data['GNU']['options'] = '-Wall' > compiler_data['GNU']['libs'] = '-lf2c' > compiler_data['GNU']['test'] = '-Wall' > compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') > > for compiler in compiler_data: > c = compiler_data[compiler] # 'GNU', 'Sun', etc. > cmd = ' '.join([c['name'], c['options'], c['libs']]) > for flag in c[flags]: > os.system(' '.join([cmd, flag, ' -o app ', files])) >> > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年06月18日 星期六 19:58
sorry, 我意思是说前面的compiler_data部分 -------------------------------------------------------------------- # data compiler_data['GNU']['type'] = 'GNU 3.0' compiler_data['GNU']['name'] = 'g77' compiler_data['GNU']['options'] = '-Wall' compiler_data['GNU']['libs'] = '-lf2c' compiler_data['GNU']['test'] = '-Wall' compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') -------------------------------------------------------------------- 在python2.3.4里面不能运行。 字典不是类似 dict1={a:b,c:d,e:f} 这样定义的吗? limodou wrote: >这是字典的用法呀。现在可以使用: >for i in d: >这种用法来遍历字典d的键值。有兴趣你自已可以试一试。 > >在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: > > >>在《python scripting for computational science》里看到的这样的用法,这是字 >>典还是? >>--- >># data >>compiler_data['GNU']['type'] = 'GNU 3.0' >>compiler_data['GNU']['name'] = 'g77' >>compiler_data['GNU']['options'] = '-Wall' >>compiler_data['GNU']['libs'] = '-lf2c' >>compiler_data['GNU']['test'] = '-Wall' >>compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') >> >>for compiler in compiler_data: >>c = compiler_data[compiler] # 'GNU', 'Sun', etc. >>cmd = ' '.join([c['name'], c['options'], c['libs']]) >>for flag in c[flags]: >>os.system(' '.join([cmd, flag, ' -o app ', files])) >>>> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >> > > > > >------------------------------------------------------------------------ > >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > >
2005年06月18日 星期六 20:04
在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: > sorry, 我意思是说前面的compiler_data部分 > > -------------------------------------------------------------------- > # data > compiler_data['GNU']['type'] = 'GNU 3.0' > compiler_data['GNU']['name'] = 'g77' > compiler_data['GNU']['options'] = '-Wall' > compiler_data['GNU']['libs'] = '-lf2c' > compiler_data['GNU']['test'] = '-Wall' > compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') > -------------------------------------------------------------------- > > 在python2.3.4里面不能运行。 > > 字典不是类似 dict1={a:b,c:d,e:f} 这样定义的吗? > 字典是这样定义没错,但是字典的值可以还是一个字典呀,如: a={} a['GNU']={} 这样就可以: a['GNU']['options'] = '-Wall'了 a['GNU']还可以写成一个对象,这个对象有__setitem__方法,可以用来摸拟a['item']这样的操作。方法很多的。 > > limodou wrote: > > >这是字典的用法呀。现在可以使用: > >for i in d: > >这种用法来遍历字典d的键值。有兴趣你自已可以试一试。 > > > >在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: > > > > > >>在《python scripting for computational science》里看到的这样的用法,这是字 > >>典还是? > >>--- > >># data > >>compiler_data['GNU']['type'] = 'GNU 3.0' > >>compiler_data['GNU']['name'] = 'g77' > >>compiler_data['GNU']['options'] = '-Wall' > >>compiler_data['GNU']['libs'] = '-lf2c' > >>compiler_data['GNU']['test'] = '-Wall' > >>compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') > >> > >>for compiler in compiler_data: > >>c = compiler_data[compiler] # 'GNU', 'Sun', etc. > >>cmd = ' '.join([c['name'], c['options'], c['libs']]) > >>for flag in c[flags]: > >>os.system(' '.join([cmd, flag, ' -o app ', files])) > >>> >> > >>_______________________________________________ > >>python-chinese list > >>python-chinese at lists.python.cn > >>http://python.cn/mailman/listinfo/python-chinese > >> > >> > >> > > > > > > > > > >------------------------------------------------------------------------ > > > >_______________________________________________ > >python-chinese list > >python-chinese at lists.python.cn > >http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年06月18日 星期六 20:50
compiler_data = {'GNU':{ }} compiler_data['GNU']['type'] = 'GNU 3.0' ...... compiler_data['GNU']也是一个字典,所以可以这样用。 ZeroSlug 写道: >sorry, 我意思是说前面的compiler_data部分 > >-------------------------------------------------------------------- ># data >compiler_data['GNU']['type'] = 'GNU 3.0' >compiler_data['GNU']['name'] = 'g77' >compiler_data['GNU']['options'] = '-Wall' >compiler_data['GNU']['libs'] = '-lf2c' >compiler_data['GNU']['test'] = '-Wall' >compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') >-------------------------------------------------------------------- > >在python2.3.4里面不能运行。 > >字典不是类似 dict1={a:b,c:d,e:f} 这样定义的吗? > > > >limodou wrote: > > > >>这是字典的用法呀。现在可以使用: >>for i in d: >>这种用法来遍历字典d的键值。有兴趣你自已可以试一试。 >> >>在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: >> >> >> >> >>>在《python scripting for computational science》里看到的这样的用法,这是字 >>>典还是? >>>--- >>># data >>>compiler_data['GNU']['type'] = 'GNU 3.0' >>>compiler_data['GNU']['name'] = 'g77' >>>compiler_data['GNU']['options'] = '-Wall' >>>compiler_data['GNU']['libs'] = '-lf2c' >>>compiler_data['GNU']['test'] = '-Wall' >>>compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') >>> >>>for compiler in compiler_data: >>>c = compiler_data[compiler] # 'GNU', 'Sun', etc. >>>cmd = ' '.join([c['name'], c['options'], c['libs']]) >>>for flag in c[flags]: >>>os.system(' '.join([cmd, flag, ' -o app ', files])) >>>>>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>> >>> >>> >> >> >>------------------------------------------------------------------------ >> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >> >> > > >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > > > >
2005年06月18日 星期六 21:06
谢谢,字典可以多重嵌套呀,很方便。 cpunion wrote: >compiler_data = {'GNU':{ }} >compiler_data['GNU']['type'] = 'GNU 3.0' >...... > > >compiler_data['GNU']也是一个字典,所以可以这样用。 > >ZeroSlug 写道: > > > >>sorry, 我意思是说前面的compiler_data部分 >> >>-------------------------------------------------------------------- >># data >>compiler_data['GNU']['type'] = 'GNU 3.0' >>compiler_data['GNU']['name'] = 'g77' >>compiler_data['GNU']['options'] = '-Wall' >>compiler_data['GNU']['libs'] = '-lf2c' >>compiler_data['GNU']['test'] = '-Wall' >>compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') >>-------------------------------------------------------------------- >> >>在python2.3.4里面不能运行。 >> >>字典不是类似 dict1={a:b,c:d,e:f} 这样定义的吗? >> >> >> >>limodou wrote: >> >> >> >> >> >>>这是字典的用法呀。现在可以使用: >>>for i in d: >>>这种用法来遍历字典d的键值。有兴趣你自已可以试一试。 >>> >>>在 05-6-18,ZeroSlug<zyf_sz at tom.com> 写道: >>> >>> >>> >>> >>> >>> >>>>在《python scripting for computational science》里看到的这样的用法,这是字 >>>>典还是? >>>>--- >>>># data >>>>compiler_data['GNU']['type'] = 'GNU 3.0' >>>>compiler_data['GNU']['name'] = 'g77' >>>>compiler_data['GNU']['options'] = '-Wall' >>>>compiler_data['GNU']['libs'] = '-lf2c' >>>>compiler_data['GNU']['test'] = '-Wall' >>>>compiler_data['GNU']['flags'] = ('-O1','-O3','-O3 -funroll-loops') >>>> >>>>for compiler in compiler_data: >>>>c = compiler_data[compiler] # 'GNU', 'Sun', etc. >>>>cmd = ' '.join([c['name'], c['options'], c['libs']]) >>>>for flag in c[flags]: >>>>os.system(' '.join([cmd, flag, ' -o app ', files])) >>>>>>>> >>>>_______________________________________________ >>>>python-chinese list >>>>python-chinese at lists.python.cn >>>>http://python.cn/mailman/listinfo/python-chinese >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>------------------------------------------------------------------------ >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>> >>> >>> >>> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >> >> >> >> >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > > > >
Zeuux © 2025
京ICP备05028076号