About 2,190,000 results
Open links in new tab
  1. python - How do I get the full path of the current file's directory ...

    2812 The special variable __file__ contains the path to the current file. From that we can get the directory using either pathlib or the os.path module. Python 3 For the directory of the script …

  2. How to get an absolute file path in Python - Stack Overflow

    Sep 9, 2008 · 1081 Given a path such as "mydir/myfile.txt", how do I find the file's absolute path in Python? E.g. on Windows, I might end up with:

  3. How should I write a Windows path in a Python string literal?

    Apr 9, 2023 · Path takes a path-like string and adjusts everything for the current OS, either Windows or Linux. For example, on Linux it would convert all backslashes to forward slashes, …

  4. python - How can I create a full path to a file from parts (e.g. path ...

    I need to pass a file path name to a module. How do I build the file path from a directory name, base filename, and a file format string? The directory may or may not exist at the time of call. ...

  5. Extract file name from path, no matter what the os/path format

    Dec 5, 2011 · Which Python library can I use to extract filenames from paths, no matter what the operating system or path format could be? For example, I'd like all of these paths to return me …

  6. python - Find the current directory and file's directory - Stack …

    How do I determine: the current directory (where I was in the shell when I ran the Python script), and where the Python file I am executing is?

  7. How do I get the path of the Python script I am running in?

    How do I get the path of a the Python script I am running in? I was doing dirname(sys.argv[0]), however on Mac I only get the filename - not the full path as I do on Windows.

  8. Reading a file using a relative path in a Python project

    Reading a file using a relative path in a Python project Asked 9 years, 2 months ago Modified 2 years, 2 months ago Viewed 283k times

  9. python - How can I find path to given file? - Stack Overflow

    Jul 14, 2009 · I have a file, for example "something.exe" and I want to find path to this file How can I do this in python?

  10. How can I extract the folder path from file path in Python?

    Although, I would recommend using the os.path.dirname function to do this, you just need to pass the string, and it'll do the work for you. Since, you seem to be on windows, consider using the …