Giter Site home page Giter Site logo

gitgitgit's People

Contributors

guylmf avatar jiafanxue avatar xie-zhibin avatar zoeywoohoo avatar

Watchers

 avatar  avatar

gitgitgit's Issues

编码问题

unicode里面是utf-8编码

>>> old = u'\xe9\xa2\x98\xe5\x90\x8d/\xe8\xb4\xa3\xe4\xbb\xbb\xe8\x80\x85:'
>>> [chr(ord(x))for x in old]
['\xe9', '\xa2', '\x98', '\xe5', '\x90', '\x8d', '/', '\xe8', '\xb4', '\xa3', '\
xe4', '\xbb', '\xbb', '\xe8', '\x80', '\x85', ':']
>>> temp=[chr(ord(x))for x in old]
>>> "".join(temp)
'\xe9\xa2\x98\xe5\x90\x8d/\xe8\xb4\xa3\xe4\xbb\xbb\xe8\x80\x85:'
>>> chr
<built-in function chr>
>>> ord
<built-in function ord>
>>> ord('A')
65
>>> ord('a')
97
>>> chr(97)
'a'

unicode 转义

>>> s='\u554a\u54c8'
>>> s.decode('unicode-escape')
u'\u554a\u54c8'

html 转义

import HTMLParser
import cgi

escape_txt = '&lt;abc&gt;'

#unescape
hp = HTMLParser.HTMLParser()
unescape_txt = hp.unescape(escape_txt )

#escape
escape_txt = cgi.escape(unescape_txt)

http://www.cnblogs.com/xuxn/archive/2011/08/12/parse-html-escape-characters-in-python.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.