relative paths connect using python

Xristos Xristoou saxri89 at gmail.com
Mon Mar 20 13:49:39 EDT 2017


Τη Δευτέρα, 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


More information about the Python-list mailing list