Rossum's tutorial on Python states:
"open() returns a file object, and is most commonly used with two
arguments: 'open(filename, mode)'
mode 'r+' opens the file for both reading and writing."
Here's a little session in Python's interactive window
[color=blue][color=green][color=darkred]
>>> f=open('mytext. txt','w+')
>>> f.write('My name is Bob')
>>> s=f.read()
>>> s.len()
>>> len(s)[/color][/color][/color]
4082[color=blue][color=green][color=darkred]
>>>f.close()[/color][/color][/color]
If I open the file mytext.txt in Notepad I see something that begins
with
"My name is Bob VwMÚ¸x¶ Ð"
and goes on for approximately 4082 characters.
What's happening??
Alex
"open() returns a file object, and is most commonly used with two
arguments: 'open(filename, mode)'
mode 'r+' opens the file for both reading and writing."
Here's a little session in Python's interactive window
[color=blue][color=green][color=darkred]
>>> f=open('mytext. txt','w+')
>>> f.write('My name is Bob')
>>> s=f.read()
>>> s.len()
>>> len(s)[/color][/color][/color]
4082[color=blue][color=green][color=darkred]
>>>f.close()[/color][/color][/color]
If I open the file mytext.txt in Notepad I see something that begins
with
"My name is Bob VwMÚ¸x¶ Ð"
and goes on for approximately 4082 characters.
What's happening??
Alex
Comment