138 of 151 menu

The getcwd method of os the module

The getcwd method of the os module returns the current working directory. We do not specify anything in the method parameter.

Syntax

import os os.getcwd()

Example

Let's find out our working directory:

import os print(os.getcwd())

The result of the executed code:

C:\python

See also

  • method listdir of module os,
    which returns a list of files in the working directory
  • method makedirs of module os,
    which creates folders
  • method mkdir of module os,
    which creates one folder
  • method path.exists of module os,
    which checks the existence of a path
  • method scandir of module os,
    which iterates through the files in a folder
  • method stat of module os,
    which returns the status of the path
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline