Код: Выделить всё
#AttributeError: 'FigureCanvasInterAgg' object has no attribute 'tostring_rgb'. Did you mean: 'tostring_argb'?
#import matplotlib.pyplot as plt
#========================
# This can be work
# import matplotlib
# matplotlib.use('TkAgg')
# import matplotlib.pyplot as plt
#=========================
with open('notebook.txt', encoding='utf-8') as file:
# contents = file.read()
# print(contents)
# for line in file:
# print('line:', line)
contents = file.readlines()
print(contents)
newList = []
for content in contents:
newContent = content.replace('\n', '')
money = newContent.split(':')[-1]
newList.append(int(money))
# 6月: 9000
# contents = content.replace('\n', '')
print(newList)
x = [1, 2, 3, 4, 5, 6]
y = newList
plt.plot(x, y, 'r')
plt.xlabel('month')
plt.ylabel('money')
plt.legend()
plt.show()
Код: Выделить всё
1月: 7000
2月: 10000
3月: 15000
4月: 12000
5月: 13000
6月: 9000
Подробнее здесь: https://stackoverflow.com/questions/793 ... ring-rgb-d