User:Simon/Trim4/tools/Python read file: Difference between revisions
< User:Simon | Trim4/tools
No edit summary |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Reading files= | ==Reading files== | ||
For Python to read a file: | For Python to read a file: | ||
<pre> | |||
with open('README.md', 'r') as txt: | with open('README.md', 'r') as txt: | ||
txt_content = txt.read() | txt_content = txt.read() | ||
print(txt_content)</pre> | |||
print(txt_content)</ |
Latest revision as of 14:41, 20 June 2020
Reading files
For Python to read a file:
with open('README.md', 'r') as txt: txt_content = txt.read() print(txt_content)