relative paths connect using python

alister alister.ware at
Mon Mar 20 14:35:30 EDT 2017

On Mon, 20 Mar 2017 10:49:39 -0700, Xristos Xristoou wrote:

> Τη Δευτέρα, 20 Μαρτίου 2017 - 7:05:33 μ.μ. UTC+2, ο χρήστης Xristos
> Xristoou έγραψε:
>> i have a little confused problem. i want to store some paths from
>> images using python 2.7 in windows 10.
>> i have some relative path like this var1='C:/my/store/path' and in the
>> final folder where in my example is the name 'path' inside that folder
>> i have some images like this :
>> -path
>>    -myimage_1010_im.png -myimage_1010_im1.png -myimage_1010_im3.png
>>    -myimage_1020_im.png -myimage_1020_im1.png
>> can i connect my relative path like var1 with the images using only the
>> number of the mid name of images and finaly i take the full original
>> path like this var1='C:/my/store/path/myimage_1010_im.png' ?
>> i try something but not work import os cwd = os.getcwd()
>> path = os.path.join(cwd, "my_file")
> i want like this a=1010 path = os.path.join(cwd, a")
> print path
> and the path i need full absolute path like this :
> var1='C:/my/store/path/myimage_1010_im.png'
> in my first code i dont have error but i take wrong for me path not full

without specifying what you expect to see & what you are actually seeing 
it is difficult for anyone to understand your problem let alon provide 
the solution. 

that said it looks like you need to develop your debugging skills so that 
you can hep yourself, try adding print statements at critical points in 
your program to check that your variables contain what you think they 
should ate each stage, this will help you pinpoint the point in your code 
you need to investigate.


print (cwd) // is cwd what you expect? if not why not
path = os.path.join(cwd,'myfile')
print (path) // is path what you expect  ?if not why not?

when you identify the part that is wrong post back with what you expect & 
what you get.
I was making donuts and now I'm on a bus!

More information about the Python-list mailing list