User:Simon/Trim4/tools/Python read file: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "For Python to read a file: <code> with open('README.md', 'r') as txt: txt_content = txt.read() print(txt_content)</code>")
 
No edit summary
Line 1: Line 1:
=Reading files=
For Python to read a file:
For Python to read a file:


<code>
<nowiki>
with open('README.md', 'r') as txt:  
with open('README.md', 'r') as txt:  


Line 7: Line 9:




print(txt_content)</code>
print(txt_content)</nowiki>

Revision as of 18:27, 15 November 2019

Reading files

For Python to read a file:

with open('README.md', 'r') as txt: 

    txt_content = txt.read() 


print(txt_content)