复制一个可迭代的类对象 [英] copy an iterable class object

查看:93
本文介绍了复制一个可迭代的类对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好每一个呀和新年快乐

i需要一些帮助

i想写一个复制清单的功能

这里是代码

展开 | 选择 | Wrap | 行号

解决方案

''l''是一个实例。复制print显示的列表:

展开 | 选择 | Wrap | 行号


我还有一个建议。不要在变量名中使用''l''(小写''L''),除非在''lucky_number'中显而易见。很多时候很难区分''l''和''1',这取决于字体。以下是一个函数,它将从您的实例l返回一个整数列表(用'''代替''l''):

展开 | 选择 | 换行 | 行号


谢谢你的答案,但我必须自己写这个功能(我不会使用预定的功能)(这是一个练习)

谢谢

Hello every ody and happy new year
i need some help
i want to write a function which copies a list
here is the code

Expand|Select|Wrap|Line Numbers

解决方案

''l'' is an instance. To copy the list displayed by print:

Expand|Select|Wrap|Line Numbers


I have one more suggestion. Do not use ''l'' (lower case ''L'') in variable names unless it is obvious as in ''lucky_number''. Many times it is difficult to distinguish between ''l'' and ''1'', depending on the font. Following is a function that will return a list of integers from your instance ''l'' (substituting ''a'' for ''l''):

Expand|Select|Wrap|Line Numbers


thank you for your answers but i must write this function by myself ( i musn''t use the predefinied functions ) (it''s an exercise )
thanks


这篇关于复制一个可迭代的类对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆