+ 1
When I create (write) a textfile in python (file = open("newfile.txt","w")) - where can I find this file on my device to edit?
After a textfile is written...
4 odpowiedzi
+ 16
@visph oh? 😄thanks for the correction. at least now I know what's right ☺
+ 14
on the same folder where your source code is saved(if you're using pc)
+ 6
@Jobelle wrote: << on the same folder where your source code is saved(if you're using pc) >>
Not necessarly at all ^^
Files are saved in the current working directory (folder), which isn't always the script directory :P (at running time if you have modifying it as well as at start)
To know what's the current working directory, you can use:
import os
print(os.getcwd())
And to get the running script directory:
import os
print(os.path.dirname(os.path.realpath(__file__)))
+ 2
If you're using the SL playground, you'll get
..\Playground\
..\Playground\
To see the contents, use print(os.listdir()), which will give you
[source.py, new file.txt]
source.py is the current script you are running.
Since newfile.txt is on the SL server not your device, you can't edit it later, and it isn't saved by SL.