relative paths connect using python

jladasky at jladasky at
Mon Mar 20 13:38:59 EDT 2017

On Monday, March 20, 2017 at 10:05:33 AM UTC-7, Xristos Xristoou wrote:
> 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 think you are new here.  In order to get the best possible assistance, you always need to share as much information as you can.

You posted your code.  That's a good start.

You did not post the error message you received. "i try something but not work" is never enough information.  Post your actual error messages as well.  What do they say?

Are you new to programming or just to Python?  Reading the error messages is sometimes hard for new programmers.  But once you can read them, you can fix your own problems.

More information about the Python-list mailing list