<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Io on Margrop Blog</title>
    <link>https://blog.margrop.net/en/tag/io/</link>
    <description>Recent content in Io on Margrop Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Fri, 26 Feb 2021 10:29:31 +0800</lastBuildDate>
    <atom:link href="https://blog.margrop.net/en/tag/io/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Python 3 I/O Programming</title>
      <link>https://blog.margrop.net/en/post/python3-io-programming/</link>
      <pubDate>Fri, 26 Feb 2021 10:29:31 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/python3-io-programming/</guid>
      <description>&lt;h1 id=&#34;file-reading-and-writing&#34;&gt;File Reading and Writing&lt;/h1&gt;&#xA;&lt;h2 id=&#34;read-reads-the-entire-file-at-once&#34;&gt;&lt;code&gt;read()&lt;/code&gt;: reads the entire file at once&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;with&lt;/code&gt; is similar to &lt;code&gt;try...catch&lt;/code&gt;, but simpler, and it automatically calls &lt;code&gt;close&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;with&lt;/span&gt; open(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/path/to/file&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;r&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; f:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    print(f&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;read())&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
