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']
2 Answers
+ 1
source.py is the file you are working with. It stores the code you typed in the playground.
+ 1
Try this:
import os
print(os.listdir())
files=os.listdir()
file=open("source.py", "r")
a=file.read()
print(a)