title: how to place a character literal in a python string
body: <p>I'm trying to write a regular expression in python, and one of the characters involved in it is the \001 character.  putting \001 in a string doesn't seem to work.  I also tried 'string' + str(chr(1)), but the regex doesn't seem to catch it.  Please for the love of god somebody help me, I've been struggling with this all day.</p>
  
  <pre><code>import sys
  import postgresql
  import re
  
  if len(sys.argv) != 2:
      print("usage: FixToDb &lt;fix log file&gt;")
  else:
      f = open(sys.argv[1], 'r')
      timeExp = re.compile(r'(\d{2}):(\d{2}):(\d{2})\.(\d{6}) (\S)')
      tagExp = re.compile('(\\d+)=(\\S*)\001')
      for line in f:
          #parse the time
          m = timeExp.match(line)
          print(m.group(1) + ':' + m.group(2) + ':' + m.group(3) + '.' + m.group(4) + ' ' + m.group(5));
          tagPairs = re.findall('\\d+=\\S*\001', line)
          for t in tagPairs:
              tagPairMatch = tagExp.match(t)
              print ("tag = " + tagPairMatch.group(1) + ", value = " + tagPairMatch.group(2))
  </code></pre>
  
  <p>Here's is an example line of for the input.  I replaced the '\001' character with a '~' for readability</p>
  
  <p>15:32:36.357227 R 1 0 0 0 8=FIX.4.2~9=0067~35=A~52=20120713-19:32:36~34=1~49=PD~56=P~98=0~108=30~10=134</p>
  
  <p>output: </p>
  
  <p>15:32:36.357227 R
  tag = 8, value = FIX.4.29=006735=A52=20120713-19:32:3634=149=PD56=P98=0108=3010=134</p>
  
  <p>So it doesn't stop at the '\001' character.</p>