python tutorial

steve steve at nospam.au
Thu Jun 18 01:58:37 EDT 2009


"Steven D'Aprano" <steven at REMOVE.THIS.cybersource.com.au> wrote in message
news:pan.2009.06.18.01.42.51 at REMOVE.THIS.cybersource.com.au...
> 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

Ok, Python makes a distinction between text and binary files.

Steve.






More information about the Python-list mailing list