易截截图软件、单文件、免安装、纯绿色、仅160KB

python string和PyQt的QString的区别

python string和PyQt的QString的区别 以下在Python2.6和PyQt4.4.4 for
Python2,6环境下讨论: Python中有两种有关字符的类型:Python string object和Python Unicode
object。主要使用Python string object进行数据输入输出。 PyQt中与之相对应的字符有关类
python string和PyQt的QString的区别
以下在Python2.6和PyQt4.4.4 for Python2,6环境下讨论:
Python中有两种有关字符的类型:Python string object和Python Unicode object。主要使用Python string object进行数据输入输出。
PyQt中与之相对应的字符有关类型是:QByteArray和QString。主要使用QString操作数据。
1. Python和PyQt中的类型对应
注意是类型相似,不是相等。
需要先了解编码:ascii、gb2312、big5,这些是各国自己文字不同的编码;unicode,国际通用编码,就是穷尽这个世界上所有的文字,给
每个文字编一个,又分utf-8方案--最常使用的128个英文字母用一个字节来表示,而中文使用三个字节来表示,utf-16方案--其中英文和中文都
使用两个字节来表示,而其它字符采用四个字节,utf-32方案--所有的文字都用四个字节来表示。
unicode就可用来作为各种独立编码如ascii、gb2312、big5的转换中介。
Python中gkb == gb2312。
1)Python string object可以理解为一个接一个字节(byte,8位)的字节组,至于表示什么编码,与表示文字有关,如:"python string","中文"。注意它是有不同编码区分的!
PyQt中与之相当的是QByteArray,注意不是QString!
A built-in string object (plain or Unicode) is a sequence of characters
used to store and represent text-based information (plain strings are
also sometimes used to store and represent arbitrary sequences of
binary bytes). (摘自《Python in a NutShell》)
QByteArray can be used to store both raw bytes (including '"0's) and traditional 8-bit '"0'-terminated.(摘自《PyQt手册》)
2)Python Unicode object可以理解为固定使用utf-16编码的字节组,其中英文和中文都使用两个字节(16位)来表示,如:u"Python Unicode object"、u"中文"。
PyQt中与之对应的就是QString了。
Unicode string literals have the same syntax as other string literals,
with a u or U immediately before the leading quote. (摘自《Python in a
NutSh


相关文档:

python安装之安装模块制作

python的egg文件有点像java中的jar文件,是一个工程打包文件,便于安装部署,仅此一点,给多少pythoner带来了多少激动。
如何制作egg文件呢?see官方文档http://peak.telecommunity.com/DevCenter/PythonEggs,
到http://pypi.python.org/pypi/setuptools下载setuptools包,然后安装:
python setup.py
1.制作egg文件
......

[python]重定向输出

  调用一个控制台程序,获取它的标准输出,或把它的标准输出重定向到界面上,这里只介绍如何获取它的标准输出,因为原理都一样的。
使用python2.5的subprocess模块来实现。
import sys
import subprocess
def RunShellWithReturnCode(command, print_output=False,
universal_newline ......

搭建python的eclipse开发环境

软件准备:
1.eclipse开发包,下载地址:http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR2/eclipse-java-galileo-SR2-win32.zip
2.pydev插件,下载地址:http://sourceforge.net/projects/pydev/files/pydev/Pydev%201.5.4/org.python.pydev.feature-1.5.4.2010011921 ......

使用pdb进行python的调试

1 在想要插入断点的地方插入代码
                import pdb
                pdb.set_trace()
2然后使用指令进行debug
查看代码上下文,l(小写L)
监视变量 ......

Python MySqlDB 增删改数据库


下载安装MySQLdb
http://sourceforge.net/projects/mysql-python/ 好像没看到windows版本for python2.6的下载,网上搜索到一个
http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
安装后import MySQLdb会出现 DeprecationWarning: the sets module is deprecated 这样一个警告,google之
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号