-1

I have a program that downloads pictures from reddit but it saves them to the folder with my py file.

How can I save these pictures to a folder called pictures?

import os

filename = "17861.jpg"
path = "E:\projects\python\Yuki.py\pic saver\pictures"
fullpath = os.path.join(path, filename)

I have tried this but it would not work.

If you can help me, thank you!

Summit
  • 5
  • 2
  • Either do `"E:\\projects\\python\\Yuki.py\\pic saver\\pictures"` or `r"E:\projects\python\Yuki.py\pic saver\pictures"` – NotAName Apr 07 '21 at 23:27
  • raw strings are a must for Windoze users. You might be able to get away with using /s; Give it a whirl. – ncmathsadist Apr 07 '21 at 23:32

1 Answers1

0

Backslashes have special meaning in Python strings. You can either use the r prefix to make it a raw string (r"E:\projects\python\Yuki.py\pic saver\pictures"), or double the backslashes ("E:\\projects\\python\\Yuki.py\\pic saver\\pictures"), or use forward slashes. All Windows APIs accept forward slashes ("E:/projects/python/Yuki.py/pic saver/pictures").

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30