r/pythonhelp • u/e4c6 • Jun 12 '20
How can I open a python file with python code?
Title. can I use the os module? can the open() function help? I just can't figure it out.
4
Upvotes
1
u/Thrasherop Jun 12 '20
Use this:
f = open("filename.txt","mode") Contents = f.read() f.write("some text") f.close()
1
u/Thrasherop Jun 12 '20
https://www.w3schools.com/python/ref_func_open.asp
There's a link to some good explanation