( 'bugger all' 'here' 'earth!'bytes substrings in python results are similarbut the unicode type is used for non-ascii textand str handles both -bit and binary textc:\codec:\python \python import re 'bugger all down here on earth! 'bugger all down here on earth!simple text and binary unicode text re match('*down *on *)'sgroups(('bugger all''here''earth!'re match('*down *on *)'ugroups(( 'bugger all' 'here' 'earth!'since bytes and str support essentially the same operation setsthis type distinction is largely transparent but note thatlike in other apisyou can' mix str and bytes types in its callsarguments in (although if you don' plan to do pattern matching on binary datayou probably don' need to care) :\codec:\python \python import re 'bugger all down here on earth! 'bugger all down here on earth!re match('*down *on *)'bgroups(typeerrorcan' use string pattern on bytes-like object re match( '*down *on *)'sgroups(typeerrorcan' use bytes pattern on string-like object re match( '*down *on *)'bytearray( )groups((bytearray( 'bugger all')bytearray( 'here')bytearray( 'earth!')re match('*down *on *)'bytearray( )groups(typeerrorcan' use string pattern on bytes-like object the struct binary data module the python struct moduleused to create and extract packed binary data from stringsalso works the same in as it does in xbut in packed data is represented as bytes and bytearray objects onlynot str objects (which makes sensegiven that it' intended for processing binary datanot decoded text)and "sdata code values must be bytes as of (the former str utf- auto-encode is droppedhere are both pythons in actionpacking three objects into string according to binary type specification (they create -byte integera -byte stringand -byte integer) :\codec:\python \python from struct import pack pack('> sh' 'spam' bytes in ( -bit stringsother string tool changes in