我只是學習Python 3中,並在他的代碼中的一些%
,見下圖:Python3:這個「%」在這段代碼中意味着什麼?
def main():
maxwidth = 100 # limita o numero de caracteres numa célula
print_start() # chama a função print_start
count = 0 # cria uma variavel cont
while True:
try:
line = input()
if count == 0:
color = "lightgreen"
elif count % 2:
color = "white"
else:
color = "lightyellow"
print_line(line, color, maxwidth)
count += 1
except EOFError:
break
print_end() # chama a função print_end
這是什麼elif count % 2:
線意味着什麼?
這是模運算符,就像在許多其他語言(C,使用Javascript,PHP)。請參閱http://www.tutorialspoint.com/python/python_basic_operators.htm – Barmar
您從中學習到什麼並不能解釋所有運營商是什麼? – Barmar
humm,感謝您的幫助 –