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

python算法实践2 shell排序

#shell排序
def ShellPass(mylist, d):
size = len(mylist)
i = d
while i < size:
if mylist[i] < mylist[i - d]:
tmp = mylist[i]
j = i - d
mylist[j + d] = mylist[j]
j = j - d
while j >= 0 and mylist[j] > tmp:
mylist[j + d] = mylist[j]
j = j - d
mylist[j + d] = tmp
i = i + d
def ShellSort(mylist):
n = len(mylist)
while n > 1:
n = n // 3 + 1
ShellPass(mylist, n)

mylist0 = [12, 11, 13, 1, 2, 4, 3, 77, 44]
ShellSort(mylist0)
print(mylist0)
 


相关文档:

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之
......

很全的Python资源收集

Programming Python, 2nd Edition (O'Reilly)
http://www.osbbs.com/dl/Programming Python, 2nd Edition (O'Reilly).chm
很全很经典了python学习入门资料
OReilly - Learning Python:
http://www.osbbs.com/dl/OReilly - Learning Python.chm ......

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 ......

关于python unicode的实验

实验环境:windows xp + vim
文件:test.py。编码:ansi
我们的目标操作test.py中保存的非英文字母。
文件头的#encoding=utf8/gbk,这个是用来说明源文件的硬盘编码以便python识别[4]。
----------------------------------------------
输入:
x = '中文'
输出: 编译失败
编译时需要知道‘中文’的硬盘编 ......

python算法实践1 直接插入排序

# 直接插入排序
def InsertSort(mylist):
size = len(mylist)
i = 1
for i in range(1, size):
if mylist[i] < mylist[i - 1]:
tmp = mylist[i]
j = i - 1
mylist[j + 1] = mylist[j]

j = j - 1
while j > ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号