python应用-打印各种形状图
row = int(input('请输入行数: ')) for row in range(1,row): for col in range (1,row+1): print( (col),end='') print() for i in range(row): for _ in range(i + 1): print('*', end='') print() for row in range(1,6): for col in range(65,65+row): print(chr(col),end='') print() for row in range(0,6): for col in range(0,row): print(chr(row+64),end='') print() for i in range(row): for j in range(row): if j < row - i - 1: print(' ', end='') else: print('*', end='') print() for i in range(row): for _ in range(row - i - 1): print(' ', end='') for _ in range(2 * i + 1): print('*', end='') print() 结果: 请输入行数: 5 1 12 123 1234 * ** *** **** A AB ABC ABCD ABCDE A BB CCC DDDD EEEEE * ** *** **** ***** * *** ***** ******* *********
千行代码,Bug何处藏。 纵使上线又怎样,朝令改,夕断肠。