python:file_handling
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python:file_handling [2016/10/18 11:29] – peter | python:file_handling [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 94: | Line 94: | ||
<file python files.py> | <file python files.py> | ||
days_file.readlines() | days_file.readlines() | ||
- | </code> | + | </file> |
Returns: | Returns: | ||
Line 126: | Line 126: | ||
new_path = '/ | new_path = '/ | ||
new_days = open(new_path,' | new_days = open(new_path,' | ||
- | Important to note, if new_days.txt already existed before opening the file its old contents would have been destroyed, so be careful when using the ' | + | </ |
+ | |||
+ | Important to note, if new_days.txt already existed before opening the file its old contents would have been destroyed, so be careful when using the **' | ||
Once our new file is opened, we can put data into the file, using the write operation, **< | Once our new file is opened, we can put data into the file, using the write operation, **< | ||
Line 158: | Line 160: | ||
<file python files.py> | <file python files.py> | ||
- | path = '/users/sammy/ | + | path = '/home/john/ |
days_file = open(path,' | days_file = open(path,' | ||
days = days_file.read() | days = days_file.read() | ||
- | + | new_path = '/home/john/ | |
- | new_path = '/users/sammy/ | + | |
new_days = open(new_path,' | new_days = open(new_path,' | ||
python/file_handling.1476790148.txt.gz · Last modified: 2020/07/15 09:30 (external edit)