Problem with Python String

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dazdh
    New Member
    • Feb 2008
    • 2

    Problem with Python String

    Hi,

    how to convert this string:
    '\\x02\\x06\\x0 b\\x01$\\x00'
    to this string:
    '\x07\xd8\x02\x 06\x0b\x01$\x00 '
    ?

    Thanks !

    Dazdh
  • dshimer
    Recognized Expert New Member
    • Dec 2006
    • 136

    #2
    Nothing original here, and you may have found it, but a search revealed the following
    Code:
    >>> s='\\x02\\x06\\x0b\\x01$\\x00'
    >>> eval("'%s'" % s)
    '\x02\x06\x0b\x01$\x00'
    >>> new=eval("'%s'" % s)
    >>> new
    '\x02\x06\x0b\x01$\x00'
    at the following


    Originally posted by dazdh
    Hi,

    how to convert this string:
    '\\x02\\x06\\x0 b\\x01$\\x00'
    to this string:
    '\x07\xd8\x02\x 06\x0b\x01$\x00 '
    ?

    Thanks !

    Dazdh

    Comment

    • dazdh
      New Member
      • Feb 2008
      • 2

      #3
      Thanks you very much. It works well.

      Comment

      Working...