1 def my_print2(char): 2     list = ['A','B','C','D','E','F'] 3     rows = (ord(char)-63) 4     rows_str = [] 5     for row in range(0,rows): 6         str = "" 7         for i in range(0,row): 8             # print(list[i],end='') 9             str += list[i]10         for i in range(row-2,-1,-1):11             # print(list[i], end='')12             str += list[i]13         rows_str.append(str)14 15     for row in range(rows-2,-1,-1):16         str = ""17         for i in range(0, row):18             # print(list[i], end='')19             str += list[i]20         for i in range(row - 2, -1, -1):21             # print(list[i], end='')22             str += list[i]23         rows_str.append(str)24 25     for str in rows_str:26         print("| %s |"%str.center(11))27 28 29 my_print2("D")

 python用for循环实现ABCD循环成菱形阵列_python