<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Python_writing_to_a_file</id>
		<title>Python writing to a file - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Python_writing_to_a_file"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Python_writing_to_a_file&amp;action=history"/>
		<updated>2026-05-06T18:31:59Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Python_writing_to_a_file&amp;diff=2894&amp;oldid=prev</id>
		<title>George2: Created page with &quot;&lt;source lang=&quot;python&quot;&gt; from sys import argv  script, filename = argv  print &quot;We're going to erase %r.&quot; % filename print &quot;If you don't want that, hit CTRL-C (^C).&quot; print &quot;If yo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Python_writing_to_a_file&amp;diff=2894&amp;oldid=prev"/>
				<updated>2016-02-16T11:21:14Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; from sys import argv  script, filename = argv  print &amp;quot;We&amp;#039;re going to erase %r.&amp;quot; % filename print &amp;quot;If you don&amp;#039;t want that, hit CTRL-C (^C).&amp;quot; print &amp;quot;If yo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from sys import argv&lt;br /&gt;
&lt;br /&gt;
script, filename = argv&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;We're going to erase %r.&amp;quot; % filename&lt;br /&gt;
print &amp;quot;If you don't want that, hit CTRL-C (^C).&amp;quot;&lt;br /&gt;
print &amp;quot;If you do want that, hit RETURN.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
raw_input(&amp;quot;?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Opening the file...&amp;quot;&lt;br /&gt;
target = open(filename, 'w')&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Truncating the file.  Goodbye!&amp;quot;&lt;br /&gt;
target.truncate()&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Now I'm going to ask you for three lines.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
line1 = raw_input(&amp;quot;line 1: &amp;quot;)&lt;br /&gt;
line2 = raw_input(&amp;quot;line 2: &amp;quot;)&lt;br /&gt;
line3 = raw_input(&amp;quot;line 3: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;I'm going to write these to the file.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
target.write(line1)&lt;br /&gt;
target.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
target.write(line2)&lt;br /&gt;
target.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
target.write(line3)&lt;br /&gt;
target.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;And finally, we close it.&amp;quot;&lt;br /&gt;
target.close()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>