This is an example of how to write to a file from a python program. It writes in text format (as opposed to binary).
This is part of a folder (a little library) of small bits of tested code that work. Things like file I/O, interrupts, GPIO definitions, print examples, etc. I don't have to re-invent the wheel every time I write a program. I can go to that folder, copy the pieces I need and be done with my program quickly and with less thrashing.
MATERIALS
Library folder
Individual files for each function (ex: FileIO.py, Array.py, ...)
PYTHON SOFTWARE LIBRARY (grouped by type and listed in order of difficulty)
001-Python Library of Tips & Tricks
• 001-Python Library of Tips & Tricks
103-Python-File Read
• 103-Python - File Read
104-Python (Text) File Write
• 104-Python (Text) File Write
105-Python - Directory File Search & Verify
• 105-Python - Directory File Search & Verify
110-Python-Floating Point Accuracy
• 110-Python-Floating Point Accuracy
120-Python - Format Numbers
• 120-Python - Formatting Numbers
130-Python - Simple Print Formatting
• 130-Python - Simple Print Formatting
140-Python - if, elif, else & CASE?
• 140-Python - if, elif, else & CASE?
201-Python - 2D Array Example
• 201-Python - 2D Array Example
202-Python - 3D Array Example
• 202-Python - 3D Array Example
210-Python - Get Multiple Variables With 1 Line of Input!
• 210-Python - User Input Multiple Variables...
211-Python - Get Multiple Variables From 1 Lin - Split/Replace Complex
• 211-Python - User Input Multiple Variables...
301-Python - Function, Simple
• 301- Python - Simple Function
302-Python - Function, Complex
• 302-Python - Function, Complex
310-Python - Random Numbers (integer & float)
• 310-Python - Random Numbers (integer & float)
500-Python - Graphics, Simple Circle Example
• 500-Python - Graphics, Simple Circle Example
701-Python - Bit Shifting (needed for I2C stuff)
• 701-Python - Bit Shifting
710-Python - Recursion
• Video