Différences entre versions de « ENG-CANSAT-PICO-LOG »
Sauter à la navigation
Sauter à la recherche
Ligne 20 : | Ligne 20 : | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
− | + | with open( 'file.txt', 'a' ) as _file: | |
+ | _file.write( "Hey, it is MicroPython\r\n" ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ENG-CANSAT-PICO-TRAILER}} | {{ENG-CANSAT-PICO-TRAILER}} |
Version du 7 mars 2022 à 00:06
En cours de traduction/élaboration. |
MicroPython File System
MicroPython board does fits an internal file system. This means that Python language on a MicroPython board can also manage files!
On a MicroPython board, you can manage files and directories. Creating them, deleting them, adding data to them, etc.
As any good implementation of Python, MicroPython can manage text files and binary files.
MicroPython file system (~100Kio) is not as large as a computer file system (10+ Gigabytes). Do not manipulate/write large amount of data on a MicroPython file-system. |
Data Logging on MicroPython
Doing data logging with MicroPython is quite easy. You just open a file and write data into it like you will do with any Python code.
Writing data to text file
The following example adds lines to the 'file.txt'. The with statement will automatically close the file when the code gets out of the with scope.
with open( 'file.txt', 'a' ) as _file:
_file.write( "Hey, it is MicroPython\r\n" )
Written by Meurisse D. for MCHobby