[Tutor] newbie needs simple file handling help
wilson edgar
babyboy@oninet.pt
Sat, 21 Apr 2001 14:53:59 -0700
This is a multi-part message in MIME format.
------=_NextPart_000_0017_01C0CA72.E5D92670
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
>>> filename =3D ("Somefile.txt")
>>> file =3D open(filename, "a")
>>> file.write("hello world")
>>> file.close()
basically all you need is open(filename, mode), where mode can be "r"- =
read only, "w" - write only, "a", - append, so it doesn't erase the data =
already in the file, it's also quite handy, because when you use it if =
the file filename does not exist it will create it.
hope that helped=20
wilson edgar
----- Original Message -----=20
From: N/A=20
To: tutor@python.org=20
Sent: Friday, April 20, 2001 11:56 PM
Subject: [Tutor] newbie needs simple file handling help
Hi, i'm trying to write a program for creating and managing LARP =
character sheets for a friend, I understand most of the basic syntax and =
data handling needed, but I can't figure out how to open and write =
strings to a text file. If it's possible could you send me the commands =
and attributes for this, unfortunatley I don't have the code I have =
written here and my linux box isn't online.
=20
any help is appreciated,
Aaron
------=_NextPart_000_0017_01C0CA72.E5D92670
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>>>> filename =3D=20
("Somefile.txt")<BR>>>> file =3D open(filename, =
"a")<BR>>>>=20
file.write("hello world")<BR>>>> file.close()</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>basically all you need is =
open(filename, mode),=20
where mode can be "r"- read only, "w" - write only, "a", - append, so it =
doesn't=20
erase the data already in the file, it's also quite handy, because when =
you use=20
it if the file filename does not exist it will create it.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>hope that helped </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>wilson edgar</FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A href=3D"mailto:not@my.house" title=3Dnot@my.house>N/A</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:tutor@python.org"=20
title=3Dtutor@python.org>tutor@python.org</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, April 20, 2001 =
11:56=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] newbie needs =
simple file=20
handling help</DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DArial size=3D2>Hi, i'm trying to write a program for =
creating=20
and managing LARP character sheets for a friend, I understand most of =
the=20
basic syntax and data handling needed, but I can't figure out how to =
open and=20
write strings to a text file. If it's possible could you send me the =
commands=20
and attributes for this, unfortunatley I don't have the code I have =
written=20
here and my linux box isn't online.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>any help is appreciated,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Aaron</FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0017_01C0CA72.E5D92670--