我输入了这段代码:
def game():
down, right = 0, 0
while 1:
for i in range(down):
print "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
for j in range(right):
print "0",
print "S",
for j in range(80 - (right + 1)):
print "0",
for i in range(38 - (down + 1)):
print "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
direction = raw_input("Direction?")
if(direction.upper() == "W"):
down -= 1
elif(direction.upper() == "S"):
down += 1
elif(direction.upper() == "A"):
right -= 1
elif(direction.upper() == "D"):
right += 1
game()
'print "S",' 应该在末尾有一个逗号,以便在我下次调用 print 函数时停止在下一行打印。
实际的事情是这样的:(我已经砍掉了一些包含“000000”的行)
S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000
为什么第一个零之间有空格?我的打印功能中没有空格。