问题描述
此问题已更新:
通过引入for循环并仅使用一个列表而不是两个列表,我设法使我的程序可以打印我想要的内容。像这样:
while i <= rows:
j = 1
while j <= seats:
k = j+(4*(i-1))
field.append("{}".format(k)) #Adds the two values to one.
j += 1
i += 1
a = 1
b = 1
for isle in range(rows):
for column in range(seats):
if a == 13:
print(" ↓ TYST AVD ↓")
if a % 4 != 0:
print(field[a-1].ljust(4),end='')
else:
print(field[a-1].ljust(4),end=''+"\n")
a += 1
b += 1
打印输出:
1 2 3 4
5 6 7 8
9 10 11 12
↓ TYST AVD ↓
13 14 15 16
17 18 19 20
21 22 23 24
我的问题是让每隔一行都被反转,即我想要这样:
1 2 3 4
8 7 6 5
9 10 11 12
↓ TYST AVD ↓
16 15 14 13
17 18 19 20
24 23 22 21
我尝试以几种不同的方式实现模数,但是我似乎无法使其工作。这与模数有关吗?还是我必须重新考虑一切?
解决方法
检查" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
Lexplore
vertical resize 30
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>
是列表还是字符串。如果是字符串,请正常打印,而不要将其分散到多个参数中。
s