0
我有一段代碼,它使用Django中的matplotlib創建一個圖像並將其保存到根目錄。我需要將matplotlib保存圖像的文件夾更改爲/ static/img文件夾。Django將文件保存到文件夾中
if (len(funcion) == 2):
plotter = plot_regions([
[(lambda x: (matrizRestricciones[0][2]-matrizRestricciones[0]
[0]*x)/matrizRestricciones[0][1],True),
(lambda x: (matrizRestricciones[1][2]-matrizRestricciones[1]
[0]*x)/matrizRestricciones[1][1],True)]], xlim=(0, 10), ylim=(0,10))
plt.grid()
plt.savefig("/static/img/imagen.png")
plt.close()
任何想法如何將它們保存在那裏?
在此先感謝。
或者,您可以編寫'plt.savefig(settings.STATIC_ROOT,'imgaen.png')' – deaspo
是的,這是訣竅。謝謝! – Guardsoul