sarah zboun
sarah zboun

Reputation: 31

How do I pass a file path in python?

I'm trying to get an image to show on the screen. I have the image file and code file in the same folder. I tried using the image file name and it said that there is no such file or directory. How do I do that?

Upvotes: 0

Views: 310

Answers (1)

Ishwar Ramdasi
Ishwar Ramdasi

Reputation: 195

I think you should try to write absolute path. you can use following code

import os
path = os.getcwd()

abs_path = path + img_name

Upvotes: 1

Related Questions