在几行上编写代码 [英] writing code over several lines

查看:65
本文介绍了在几行上编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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 python
program. but the list is too big for one line. is there any
possibility to spread the list over several lines, so that the code
looks 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 advance
dominik

推荐答案

做****** @ student.ethz.ch (Dominik Kaspar)写道:
do******@student.ethz.ch (Dominik Kaspar) wrote:
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]]
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]]




我可以建议尝试以上操作,看看会发生什么吗?



Might I suggest trying the above and seeing what happens?


Dominik Kaspar写道:
Dominik Kaspar wrote:
我想初始化一个常量列表a一个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]]

提前致谢
dominik
i want to initialize a constant list at the beginning of a python
program. but the list is too big for one line. is there any
possibility to spread the list over several lines, so that the code
looks 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 advance
dominik




:)是的。只需输入代码并将其提供给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.


只是一些编码的想法:

列表= [

[100,101,102]

,[200,201,202]

,[300,301,302]

,.....

]

可以让事情更清晰,有时甚至更糟。


鲍里斯


星期五,2003年10月17日06:56:48 -0700,Dominik Kaspar写道:
Just some coding ideas :
List = [
[100,101,102]
, [200,201,202]
, [300,301,302]
, .....
]
Can make things clearer and sometimes worse.

Boris

On Fri, 17 Oct 2003 06:56:48 -0700, Dominik Kaspar wrote:
我想在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]]

提前致谢
dominik
i want to initialize a constant list at the beginning of a python
program. but the list is too big for one line. is there any
possibility to spread the list over several lines, so that the code
looks 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 advance
dominik






这篇关于在几行上编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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