0

What's in workdir of code playground ?

to see the created file in code playground : file = open("newfile.txt", "w") file.write("This has been written to a file") file.write(", or am I wrong ?") file.close() file = open("newfile.txt", "r") print(file.read()) file.close() import os print(os.listdir()) it prints [`newfile.txt','source.py']

15th Nov 2016, 4:14 PM
Bruno Greco
Bruno Greco - avatar
2 Answers
+ 1
source.py is the file you are working with. It stores the code you typed in the playground.
5th Mar 2017, 4:25 PM
Anselm
+ 1
Try this: import os print(os.listdir()) files=os.listdir() file=open("source.py", "r") a=file.read() print(a)
5th Mar 2017, 4:28 PM
Anselm