open() function python default directory

后端 未结 7 1460
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 00:23

I\'m new and I have no idea where the default directory for the open() function is.

For example open(\'whereisthisdirectory.txt\',\'r\')

7条回答
  •  青春惊慌失措
    2021-01-05 01:02

    If you working on Windows OS first type

    import os
    

    then type

    os.getcwd()
    

    and it should print the current working directory.

提交回复
热议问题