python - 我该如何修改这段代码,以便它能正确打印图案?

标签 python

for i in range(2):    
    for j in range(1,11):
        print(j," ",end="")
    print()

我需要打印这个模式,但我不知道如何让它在下一行减去 1。请帮忙。

1 2 3 4 5 6 7 8 9 10

0 1 2 3 4 5 6 7 8 9

最佳答案

这是你的意思吗?

for i in range(2):
    for j in range(1, 11):
        print(j - i, end=" ")
    print()

关于python - 我该如何修改这段代码,以便它能正确打印图案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52585210/

相关文章:

python - 在 Pandas DataFrame 中创建多列的所有可能组合

python - 如何在 Pandas DataFrame 上编写条件数组操作

python - 给视频捕获增加X延迟

Python 3 类型错误 : utf_8_encode() must be str not bytes using Requests

python - Dictreader 和正则表达式,索引问题

python - Cython 优化 numpy 数组求和的关键部分

python - 通过sqlalchemy在postgresql中有两个序列键

python - 在 python 中使用 VAR 模型进行条件预测

Python 序列翻译

python - 如何覆盖父类中的字段