Code: Select all
f = open('/flash/thefile.txt', 'w')
f.write('Hello World\n')
f.close()
However if I run the code from REPL the code run as well and after I call os.listdir() the file is in the list. But after I reset the pyboard and check the /flash from file manager, the file doesn't exist. I assume that when we run program from REPL, the program run in memory and not actually written to the /flash. Is that true? Then how can we write file from REPL?
I ask this because I want to save code to main.py via serial port. I am currently developing web application for micropython as you can see in this thread http://forum.micropython.org/viewtopic.php?f=5&t=637. The app can now write file but via filesystem API. I think it would be easier if it can save code to file via Serial.