import os with open('example_cross_platform.txt', 'w') as file:
|
|||||||||||||||
OS Agnostic Newline with Python |
|||||||||||||||
|
2 Points, by ianegan 1y ago
The os.linesep variable provides the appropriate newline character(s) for the operating system your Python code is running on. Using os.linesep allows your file operations to be compatible across different systems without manually adjusting newline characters. Take a look:
import os with open('example_cross_platform.txt', 'w') as file:
Answer Count: 1
|
|||||||||||||||