Results 1 to 5 of 5

Thread: Python converting &#number;

  1. #1
    Join Date
    Dec 2008
    Beans
    Hidden!

    Question Python converting &#number;

    I was curious, is there a way for a python program to convert an input string like this:
    "~"
    to this?:
    "~"
    Last edited by NoBugs!; July 2nd, 2009 at 04:59 PM.

  2. #2
    Join Date
    Jun 2006
    Beans
    Hidden!

    Re: Python converting &#number;

    chr(126)

    Remove the &# and enter the ASCII number for the character you want.

    http://docs.python.org/library/functions.html#chr
    arch 2008.06
    Intel Core 2 Extreme QX6850 | Asus Maximus II Formula | EVGA 8800GT Superclocked | 4GB G.Skill DDR2-1000 | Zalman ZM600-HP

  3. #3
    Join Date
    Dec 2008
    Beans
    Hidden!

    Re: Python converting &#number;

    It seems there's no quick shortcut to change &amp;lt; or &amp;#60; to < ?
    or convert &amp;cent; or &amp;#162; to ¢ ?

    Or would html parser be appropriate for this?

  4. #4
    Join Date
    Nov 2006
    Location
    Israel
    Beans
    765
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Python converting &#number;

    Had a look around - check out the module htmlentitydefs.

    Specifically, htmlentitydefs.name2codepoint.
    Intel E6300 / MSI P4M890M / 2GB DDR2 677 / 80GB + 1TB SATA2 / GeForce 6200TC / DL DVD+-RW / Dell 24" U2410

  5. #5
    Join Date
    Dec 2008
    Beans
    Hidden!

    Re: Python converting &#number;

    Thanks. I think I found a good example of that here:
    http://bytes.com/groups/python/55593...-html-entities

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •