user2512443
user2512443

Reputation: 473

How to save jpg file into a folder in python

This question seems really easy, but I could not figure that out. I want to save a jpg file. I used plt.savefig(fileName). I also create a new folder using import os and then os.mkdir('D:\Users\data'). Now, I want to put this figure into this created folder. Thanks in advance ...

Upvotes: 1

Views: 4552

Answers (1)

Lev Levitsky
Lev Levitsky

Reputation: 65791

Just pass the full path to savefig.

folderName = 'D:/Users/data'
os.makedirs(folderName)
plt.savefig(os.path.join(folderName, fileName))

Upvotes: 3

Related Questions