我想使用“*”或任何其他给定的特殊字符(如点阵打印机的工作方式)打印任何英文字母。
我可以想出一个函数def printLetters(string, font_size, special_char):
,当与任何字母一起传递时,它会使用指定的特殊字符打印该字母。
考虑字母“A”:
def printLetters('A', 10, '&'): # would print the letter A within a 10x10 matrix using '&'
&&&&&&&&
& &
& &
& &
&&&&&&&&&&
& &
& &
& &
& &
& &
以及每个字符的此类代码片段。“A”的示例:
FUNCTION_TO_PRINT_A:
space = ' '
#print first line
print('', special_char*(font_size-2))
for i in range(1, font_size-1):
#print(i)
if font_size//2 == i:
print(special_char*(font_size))
print(special_char, space*(font_size-2), special_char, sep = '')
printLetters('A', 10, "&")
但是当参数string
有多个字符时,它会在第一个字符后打印乱码。
所以我只想要一些想法/代码片段,它们将首先打印所有字符的第一行,string
依此类推,直到最后一行,以便所有这些字符在控制台上水平并排排列。