'#/usr/bin/env python \nthe raw string form in the second command is still useful to turn off accidental escapes when you can' control string contentand in other contexts text and binary filesthe short story strictly speakingthe example in the prior section uses text files in both python and xfile type is determined by the second argument to openthe mode string--an included "bmeans binary python has always supported both text and binary filesbut in python there is sharper distinction between the twotext files represent content as normal str stringsperform unicode encoding and decoding automaticallyand perform end-of-line translation by default binary files represent content as special bytes string type and allow programs to access file content unaltered in contrastpython text files handle both -bit text and binary dataand special string type and file interface (unicode strings and codecs openhandles unicode text the differences in python stem from the fact that simple and unicode text have been merged in the normal string type--which makes sensegiven that all text is unicodeincluding ascii and other -bit encodings because most programmers deal only with ascii textthey can get by with the basic text file interface used in the prior exampleand normal strings all strings are technically unicode in xbut ascii users will not generally notice in facttext files and strings work the same in and if your script' scope is limited to such simple forms of text if you need to handle internationalized applications or byte-oriented datathoughthe distinction in impacts your code (usually for the betterin generalyou must use bytes strings for binary filesand normal str strings for text files moreoverbecause text files implement unicode encodingsyou should not open binary data file in text mode--decoding its content to unicode text will likely fail let' look at an example when you read binary data file you get back bytes object -- sequence of small integers that represent absolute byte values (which may or may not correspond to characters)which looks and feels almost exactly like normal string in python xand assuming an existing binary filedata open('data bin''rb'read(data '\ \ \ \ spam\ \ data[ : 'spamdata[ : ][ open binary filerb=read binary bytes string holds binary data act like strings but really are small -bit integers files