What exactly is Current working directory?

后端 未结 4 912
一整个雨季
一整个雨季 2021-01-20 16:10

My book states:

Every program that runs on your computer has a current working directory, or cwd. Any filenames or paths that do not begin with the r

4条回答
  •  无人及你
    2021-01-20 16:50

    This has nothing to do with osx in particular, it's more of a concept shared by all unix-based systems, and I believe Windows as well. os.getcwd() is the equivalent of the bash pwd command - it simply returns the full path of the current location in which you are in. In other words:

    alex@suse:~> cd /
    alex@suse:/> python
    Python 2.7.12 (default, Jul 01 2016, 15:34:22) [GCC] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> os.getcwd()
    '/'
    

    It depends from where you started the python shell/script.

提交回复
热议问题