This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = "你好" | |
>>> a | |
'\xe4\xbd\xa0\xe5\xa5\xbd' | |
>>> b = u"你好" | |
>>> b | |
u'\u4f60\u597d' | |
>>> print a | |
你好 | |
>>> print b | |
你好 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warning (from warnings module): | |
File "C:\GitHub\FixedPointOfSimsimi\fpos.py", line 24 | |
count = count+1 if answer==question or answer==temp else 0 | |
UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal | |
不同编码方式的变量就行了 == 比较 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.2 |EPD 7.2-2 (32-bit)| (default, Sep 14 2011, 11:02:05) [MSC v.1500 32 bit (Intel)] on win32 | |
Type "copyright", "credits" or "license()" for more information. | |
>>> err = u'\u6c39' | |
>>> print err | |
氹 | |
>>> err.encode("gb2312") | |
Traceback (most recent call last): | |
File "<pyshell#2>", line 1, in <module> | |
err.encode("gb2312") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env monkeyrunner | |
# Script Name: androidviewclient.py | |
# Author Email: huangqimin@baidu.com | |
# Note: | |
# 1、 主页: | |
# https://github.com/dtmilano/AndroidViewClient | |
# 2、 例子 | |
# https://github.com/dtmilano/AndroidViewClient/blob/master/AndroidViewClient/examples/envsetup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、模块作用 | |
chardet模块用来实现字符串/文件编码检测 | |
2、chardet下载与安装 | |
下载地址:http://pypi.python.org/pypi/chardet/ | |
下载chardet后,解压chardet压缩包,直接将chardet文件夹放在应用程序目录下,就可以使用import chardet开始使用chardet了。 | |
也可以将chardet拷贝到Python系统目录下,这样你所有的python程序只要用import chardet就可以了。 | |
Python第三方模块中一般会自带setup.py文件,在CMD里切换目录至chardet,然后执行:python setup.py install。 | |
如果执行上述命令,报错:ImportError: No module named setuptools,则要进行setuptools的安装。 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For IDLE | |
Python 2.7.2 |EPD 7.2-2 (32-bit)| (default, Sep 14 2011, 11:02:05) [MSC v.1500 32 bit (Intel)] on win32 | |
Type "copyright", "credits" or "license()" for more information. | |
>>> import sys | |
>>> sys.getdefaultencoding() | |
'ascii' | |
>>> str_Chinese = "电源管理" | |
>>> print "".join(["%"+str(hex(ord(x)))[2:] for x in str_Chinese.decode("gb2312").encode("utf8")]) | |
%e7%94%b5%e6%ba%90%e7%ae%a1%e7%90%86 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request URL:http://byhh.net/cgi-bin/bbssnd?board=test&file= | |
Request Method:POST | |
Status Code:200 OK | |
Request Headersview source | |
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 | |
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3 | |
Accept-Encoding:gzip,deflate,sdch | |
Accept-Language:zh-CN,zh;q=0.8 | |
Cache-Control:max-age=0 | |
Connection:keep-alive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 | |
Type "copyright", "credits" or "license()" for more information. | |
>>> import json | |
>>> json_str = "{'json':'str'}" | |
>>> json.loads(json_str) | |
Traceback (most recent call last): | |
File "<pyshell#2>", line 1, in <module> | |
json.loads(json_str) | |
File "E:\Python27\lib\json\__init__.py", line 326, in loads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FUNCTIONS | |
get(using=None) | |
Return a browser launcher instance appropriate for the environment. | |
open(url, new=0, autoraise=True) | |
open_new(url) | |
open_new_tab(url) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python有大量的Standard Library(http://docs.python.org/2/library/),同时也有大量的第三方Library | |
(http://pypi.python.org/pypi),如此众多的Library,总有一些会给你带来意想不到的惊喜,这里向大家介绍一下, | |
requests模块(http://pypi.python.org/pypi/requests/0.14.2),可以更方便的进行网络协议相关的处理,大家可 | |
以将该模块看成是,对Python Standard Library urllib2的进一步封装。 | |
官方网址:http://docs.python-requests.org/en/latest/ | |
API列表:http://docs.python-requests.org/ | |
一些人的讨论:https://gist.github.com/973705 | |
Windows安装: |