Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 9 maj 2017 · import os def find_project_root(start_dir): """Find the root directory of a project containing a .git directory. Usage: find_project_root(os.path.dirname(os.path.abspath(__file__))) Args: start_dir (str): The directory to start the search from.""" current_dir = start_dir while True: if os.path.exists(os.path.join(current_dir, '.git')): return ...

  2. 19 sty 2018 · Windows doesn't have a single filesystem root. The best you can do portably is to get the root of the filesystem's current directory (assuming the current directory is called '.'). The expression to get that value is: os.path.abspath ('.').split (os.path.sep) [0]+os.path.sep.

  3. 18 sie 2023 · In this Byte, we've explored different ways to determine the root project directory path in Python. We've seen how to dynamically retrieve the root project directory path using the os module, leverage os.curdir for the root directory, and import the ROOT_DIR variable.

  4. 10 kwi 2024 · To get the path of the root project directory: Use the os.path.abspath() method to get a normalized absolute path to the current file. Use the os.path.dirname() method to get the directory name of the path. For example, suppose we have the following project structure.

  5. 1 dzień temu · Source code: Lib/genericpath.py, Lib/posixpath.py (for POSIX) and Lib/ntpath.py (for Windows). This module implements some useful functions on pathnames. To read or write files see open (), and for accessing the filesystem see the os module.

  6. 18 lut 2018 · Windows has drives (C:, D:, X: etc) and backslashes or double backslashes, e.g. C:\Users\JohnSmith is the same as C:\\Users\\JohnSmith. On Linux, there are no drives (per se) and forward slashes, e.g. /home/name. The best way to get a feel for paths is by using os. Try typing this into your python terminal print(os.path.abspath('.'))

  7. On Windows, paths are written using backslashes (\) as the separator between folder names. On Unix based operating system such as macOS, Linux, and BSDs, the forward slash (/) is used as the path separator. Joining paths can be a headache if your code needs to work on different platforms.

  1. Ludzie szukają również