In Python, what commands can I use to find:
To get the full path to the directory a Python file is contained in, write this in that file:
* Python 獲取文件路徑及文件目錄(__file__ 的使用方法)
1. the current directory (where I was in the terminal when I ran the Python script), and
2. where the file I am executing is?
* The os and os.path modules.
* The __file__ constant
* os.path.realpath(path) (returns "the canonical path of the specified filename, eliminating any symbolic links encountered in the path")
* os.path.dirname(path) (returns "the directory name of pathname path")
* os.getcwd() (returns "a string representing the current working directory")
* os.chdir(path) ("change the current working directory to path")
Source From Here Comparisons, Masks, and Boolean Logic This section covers the use of Boolean masks to examine and manipulate values wit...