图的存在,让数据变得形象化.无论多么复杂的东西,都是简单的组合. import matplotlib.pyplot as plt import numpy as np dict = {'A': 40, 'B': 70, 'C': 30, 'D': 85} for i, key in enumerate(dict):#Circulate both index and value(Here is key) plt.bar(i, dict[key], color='r', width=0.2) plt
方法一 n = int(input('请输入:')) for i in range(1, n, 2): print(('*'*i).center(n)) for i in reversed(range(1, n-1, 2)): print(('*'*i).center(n)) 方法二 n = int(input('请输入:')) i = 1 while i <= n: print((n-i)*' '+'* '*i) i += 1 while n < i < 2*n: print((i-n