i'm trying to programm a photo seeker. I have an issue when i wanted to open these photo from a list of path.
I put the list of path in a listBox, so i can click on choosen path and it stocks it in a string variable but i get an issue when i wanted to open the file.
I searched and i found 2 topics on stack overflow : Python os module open file above current directory with relative path
import os.path
import sys
basepath = os.path.dirname(__file__)
filepath = os.path.abspath(os.path.join(basepath, "HelloWord.txt"))
f = open(filepath, "r")
I get an error :
File "C:/Users/jguillot/Desktop/test002.py", line 6, in <module>
f = open(filepath, "r")
TypeError: an integer is required
I don't understand it.
I also look at this topic : Open file in a relative location in Python which have the same solution as the first one.
To understand my error i go on : https://docs.python.org/2/library/os.path.html I did :
import os
from os import path
os.path.exits('C:\Users\jguillot\Desktop\HelloWord.txt')
It returns me False
But if i try :
os.path.exits('C:\Users\jguillot\Desktop')
It returns me True
os.path.exists(path) : Return True if path refers to an existing path. Returns False for broken symbolic links. On some platforms, this function may return False if permission is not granted to execute os.stat() on the requested file, even if the path physically exists. (From python manual) I don't understand this error.
Can you explain to me please?