本文介绍了在几行上编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在python 程序的开头初始化一个常量列表。但是这个列表对于一行来说太大了。是否有任何 的可能性将列表分散到几行,这样代码 看起来又整齐了? 类似于: LIST = [[100,101,102],[200,201,202],[300,301,302], [400,401,402 ],[500,501,502],[600,601,602], [700,701,702],[800,801,802],[900,901,902]] 提前感谢 多米尼克i want to initialize a constant list at the beginning of a pythonprogram. but the list is too big for one line. is there anypossibility to spread the list over several lines, so that the codelooks neat again?something like:LIST = [[100, 101, 102], [200, 201, 202], [300, 301, 302],[400, 401, 402], [500, 501, 502], [600, 601, 602],[700, 701, 702], [800, 801, 802], [900, 901, 902]]thanks in advancedominik推荐答案 我可以建议尝试以上操作,看看会发生什么吗?Might I suggest trying the above and seeing what happens? :)是的。只需输入代码并将其提供给python解释器: LIST = [[100,101,102],[200,201,202],[300,301,302], [400,401,402],[500,501,502],[600,601,602], [700,701,702],[800 ,801,802],[900,901,902]] 打印列表 [[100,101,102],[200,201, 202],[300,301,302],... 问候, anton。:) yes. Just type the code and feed it to python interpreter:LIST = [[100, 101, 102], [200, 201, 202], [300, 301, 302],[400, 401, 402], [500, 501, 502], [600, 601, 602],[700, 701, 702], [800, 801, 802], [900, 901, 902]]print LIST[[100, 101, 102], [200, 201, 202], [300, 301, 302], ...regards,anton. 这篇关于在几行上编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 12:32
查看更多