Writing to a text file python

Asked 2 years ago, Updated 2 years ago, 28 views

I'm a beginner.
Write to a text file. Not reflected.
If you don't have a file, it says in the textbook that the file is created in the current directory, but I don't even know where the current directory is.

python

2022-09-30 21:37

1 Answers

The location of the current directory can be found in os.getcwd().

importos
print(os.getcwd())

Save to the folder specified here.
To change folders, use os.chdir("folder path").


2022-09-30 21:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.