Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.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 将数字1-100打印成10行_Python - Fatal编程技术网

Python 将数字1-100打印成10行

Python 将数字1-100打印成10行,python,Python,我想用这种格式打印数字1-100 12345678910 11 12 13 14 15 16 17 18 19 20 21222242527282930 等等 但是我找不到一种有效的方法,有更有效的方法,但是看起来你刚刚开始使用python,试着使用for循环遍历每一行10次 for i in range(10): for j in range(1, 11): print(i * 10 + j, end=" ") print() 我想看看mods在Python中是如何工作的。例

我想用这种格式打印数字1-100

12345678910 11 12 13 14 15 16 17 18 19 20 21222242527282930

等等


但是我找不到一种有效的方法,有更有效的方法,但是看起来你刚刚开始使用python,试着使用for循环遍历每一行10次

for i in range(10):
  for j in range(1, 11):
    print(i * 10 + j, end=" ")
  print()

我想看看mods在Python中是如何工作的。例如:

此列表仅用于其副作用打印;结果列表本身未被使用。

您可以试试这个

代码:

输出:


请展示你已经尝试过的,这样我们可以帮助你进步。
for i in range(1, 101):
  print(i, end=" ")
  if(i%10==0):
      print("\n")
[print(i, end=" ") if i % 10 else print(i) for i in range(1, 101)]
lst = list(range(1,11))
numrows = 5  #Decide number of rows you want to print

for i in range(numrows):
    print [x+(i*10) for x in lst]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
[31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50]