Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
Python 列表/元组中嵌套元素的深度有问题_Python - Fatal编程技术网

Python 列表/元组中嵌套元素的深度有问题

Python 列表/元组中嵌套元素的深度有问题,python,Python,在我在stackoverflow中找到许多有用的提示之前,我第一次在这里输入,现在我的大脑中有一个黑洞,不知道如何解决这个问题: 我得到: dirlist = ['dir1', 'dir2', 'dir3', 'dir4'] print [('a','b','c'),('x','y','z'),[('/tmp/9/', 'X', e) for e in dirlist ] ] ant it输出: [('a', 'b', 'c'),('x', 'y', 'z'), [('/tmp

在我在stackoverflow中找到许多有用的提示之前,我第一次在这里输入,现在我的大脑中有一个黑洞,不知道如何解决这个问题:

我得到:

    dirlist = ['dir1', 'dir2', 'dir3', 'dir4']
    print [('a','b','c'),('x','y','z'),[('/tmp/9/', 'X', e) for e in dirlist ] ]
ant it输出:

[('a', 'b', 'c'),('x', 'y', 'z'), [('/tmp/9/', 'X', 'dir1'), ('/tmp/9/', 'X', 'dir2'), ('/tmp/9/', 'X', 'dir3'), ('/tmp/9/', 'X', 'dir4')]]
我想:

[('a', 'b', 'c'),('x', 'y', 'z'), ('/tmp/9/', 'X', 'dir1'), ('/tmp/9/', 'X', 'dir2'), ('/tmp/9/', 'X', 'dir3'), ('/tmp/9/', 'X', 'dir4')]
。。。而真正的问题是,我需要在一行中,在print语句中这样做。
谢谢你的建议,需要帮助。

你需要一行完成作业?我应该在35分钟前寻求帮助。。。所以我已经睡觉了,谢谢你。该死的附加arggrr。。。
print [('a', 'b', 'c'), ('x', 'y', 'z')] + [('/tmp/9/', 'X', e) for e in dirlist]