小编Lüt*_*aya的帖子

尝试使用append方法在同一行中打印多个文本,但输出不同

尝试在单行中将可能的数字组合打印为列表,但是列表输出错误。我的输出是这样的:

[[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]
Run Code Online (Sandbox Code Playgroud)

什么时候应该是这样的:

[0, 0, 0]
[0, 0, 1]
[0, 1, 0]
[0, 1, 1]
[1, 0, 0]
[1, 0, 1]
[1, 1, 0]
[1, 1, 1]
Run Code Online (Sandbox Code Playgroud)

我的代码是

if __name__ == '__main__':
    x = 1
    y = 1
    z = 1 
kordinat = ["x","y","z"]
result = []
for xx in range(x+1):
    kordinat[0] = xx
    for yy in …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

3
推荐指数
1
解决办法
97
查看次数

标签 统计

python ×1

python-3.x ×1