python tutorial

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Jun 18 03:42:51 CEST 2009


On Thu, 18 Jun 2009 10:36:01 +1000, steve wrote:

> 1) Windows does not make a distinction between text and binary files.

Of course it does.


Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> f = open("test", "wb")
>>> f.write("abc\x1Adef")
>>> f.close()
>>> f = open("test", "r")  # read as text
>>> f.read()
'abc'
>>> f.close()
>>> f = open("test", "rb")  # read as binary
>>> f.read()
'abc\x1adef'
>>> f.close()
>>>


-- 
Steven



More information about the Python-list mailing list