<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>File Read/Write on 세모난 책</title><link>https://semonan.com/kr/tags/file-read/write/</link><description>Recent content in File Read/Write on 세모난 책</description><generator>Hugo</generator><language>ko-KR</language><lastBuildDate>Mon, 26 Aug 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://semonan.com/kr/tags/file-read/write/rss.xml" rel="self" type="application/rss+xml"/><item><title>Read/Write a file</title><link>https://semonan.com/kr/book/programming/python/file-io/</link><pubDate>Mon, 26 Aug 2024 00:00:00 +0000</pubDate><guid>https://semonan.com/kr/book/programming/python/file-io/</guid><description>&lt;h1 id="python의-파일-읽고-쓰는-방법"&gt;Python의 파일 읽고 쓰는 방법&lt;a class="anchor" href="#python%ec%9d%98-%ed%8c%8c%ec%9d%bc-%ec%9d%bd%ea%b3%a0-%ec%93%b0%eb%8a%94-%eb%b0%a9%eb%b2%95"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Python으로 file을 읽고 쓰는 방법을 설명합니다.&lt;br&gt;
가장 많이 사용되는 예제코드 위주로 정리하였습니다.&lt;/p&gt;
&lt;h2 id="1-text-파일-읽기---파일-전체를-읽기"&gt;1. Text 파일 읽기 - 파일 전체를 읽기&lt;a class="anchor" href="#1-text-%ed%8c%8c%ec%9d%bc-%ec%9d%bd%ea%b8%b0---%ed%8c%8c%ec%9d%bc-%ec%a0%84%ec%b2%b4%eb%a5%bc-%ec%9d%bd%ea%b8%b0"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;다음과 같이 &lt;code&gt;open(&amp;quot;abcd.txt&amp;quot;, &amp;quot;r&amp;quot;)&lt;/code&gt;를 이용하여 file stream을 생성하고, &lt;code&gt;.read( )&lt;/code&gt;를 통하여 파일 전체를 한번에 읽을 수 있습니다.&lt;br&gt;
(file stream을 생성한다는 것은 파일에 접근할 수 있는 연결고리를 만든다는 의미입니다.)&lt;br&gt;
여기서 &lt;code&gt;&amp;quot;abcd.txt&amp;quot;&lt;/code&gt;는 읽을 파일 이름을 포함한 전체 경로를 의미하며 절대경로 및 상대경로를 사용할 수 있습니다.&lt;br&gt;
&lt;code&gt;&amp;quot;r&amp;quot;&lt;/code&gt;은 read mode 를 의미합니다.&lt;/p&gt;</description></item></channel></rss>