Posted By


tamuratetsuya on 03/09/09

Tagged


Statistics


Viewed 731 times
Favorited by 0 user(s)

URIエンコードとデコードにはurllibモジュールのquote()とunquote()が使へる


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # -*- coding: utf-8; -*-
  2.  
  3. import urllib
  4.  
  5. print urllib.quote('いろはにほへと')
  6. print urllib.quote(u'いろはにほへと'.encode('euc-jp'))
  7. print urllib.quote(u'いろはにほへと'.encode('shift_jis'))
  8. print urllib.quote(u'いろはにほへと'.encode('iso-2022-jp'))
  9. print urllib.quote(u'いろはにほへと')
  10. print urllib.unquote('%E3%81%84%E3%82%8D%E3%81%AF%E3%81%AB%E3%81%BB%E3%81%B8%E3%81%A8')

URL: http://python.g.hatena.ne.jp/mhrs/20060609/p1

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.