Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 用括号打印列表中的元素_List_Printing_Format - Fatal编程技术网

List 用括号打印列表中的元素

List 用括号打印列表中的元素,list,printing,format,List,Printing,Format,我想打印列表中的元素,其中每个元素都由一个括号集绑定[element] 我想知道如何使它看起来像这样: a=[1,2,5,6] 要打印: [1] [2][5][6] 谢谢 JAVA for(int i:list) { System.out.print("["+i+"]"); } C# 在Python2.7中 for x in a: print [x], 在蟒蛇3中 for x in a: print([x], end='') 你想用什么语

我想打印列表中的元素,其中每个元素都由一个括号集绑定
[element]

我想知道如何使它看起来像这样:

a=[1,2,5,6]

要打印:

[1] [2][5][6]

谢谢

JAVA

   for(int i:list)
    {
       System.out.print("["+i+"]");
    }
C#

在Python2.7中

for x in a:
    print [x],
在蟒蛇3中

for x in a:
    print([x], end='')

你想用什么语言来做这件事?虽然这个代码片段可以解决这个问题,但确实有助于提高你文章的质量。请记住,您将在将来回答读者的问题,这些人可能不知道您的代码建议的原因。
for x in a:
    print([x], end='')