【发布时间】:2017-07-17 16:52:48
【问题描述】:
编写一个使用以下标头打印字符的函数:def printChars(ch1, ch2, numberPerLine):
此函数打印ch1 和ch2 之间的字符,每行带有指定的数字。
我想编写一个测试程序,从 1 到 Z 每行打印十个字符。
def main():
printCenter code herehars("1","Z",10)
def printChars(ch1,ch2,numberPerLine):
for i in range(ord(ch1), ord(ch2) + 1):
print(chr(i), end='')
if (i - ord(ch1)) % numberPerLine == numberPerLine - 1:
print()
main()
输出:
123456789:
;<=>?@ABCD
EFGHIJKLMN
OPQRSTUVWX
YZ
程序应该打印:
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ
【问题讨论】: