I'm a Python newbie and I'm running into a problem that I feel like should have a relatively straight forward answer that I can't quite figure out.
I need to do it this way for an assignment as our teacher wants our GitHub folder to contain all the code in one folder and all of the images in another folder.
Since I will be in the Code folder when running the Python file, is there a way I can reference the Image Folder? Locally, I know I can just put the full path, but because this will be done through command line for GitHub, I wasn't sure what the full path even looked like to reference that folder.
+ Main GitHub Directory
+ Code Folder
-My Python File
+ Image Folder
-Images I want to use
This is just a sample program of what I would like to do:
from PIL import Image
image = Image.open('WeatherIcons/Code32.PNG')
image.show()
This will work if 'WeatherIcons' is a subfolder of the Code Folder
, but not when it is at the same level. Any creative solutions to get around this?
Thank you!
Use the path:
../Image_Folder/Code32.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With