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

Python模块随想随记

时常见到一些好的Python模块,如果不随时记下,等用的时候又是一阵乱翻,好在Python引用一个模块极其方便,OK,废话少说:
1. decimal
标准模块,2.4引入,用于浮点数的精确表示:
>>> 0.1 + 0.1 + 0.1 - 0.3
5.5511151231257827e-17
>>> from decimal import Decimal
>>> def _(x): return Decimal(str(x))
...
>>> _(0.1)+_(0.1)+_(0.1)+_(-0.3)
Decimal('0.0')


相关文档:

python算法实践5 直接选择排序

#直接选择排序
def SelectSort(mylist):
size = len(mylist)
i = 0
for i in range(0, size):
k = i
for j in range(i + 1, size):
if mylist[j] < mylist[k]:
k = j

if k != i:
tmp = mylist[i]
......

python,c++,C#随机数生成

先说python
python的random模块提供了多个伪随机数发生器,默认都是用当前时间戳为随机数种子。
下面是该模块几个最常用的函数
random() Return the next random floating point number in the range [0.0, 1.0). 
randint(a,b) Return a random integer N such that a <=
N <= b
randrange([star ......

python学习1 使用类

#使用类
class CPerson:
#类变量好比C++中的静态成员变量
population = 0

def SayHi(self):
print('Hello World')
def HowMany(self):
if CPerson.population == 1:
print('I am the only person here.')
else:
print(('We have %d perso ......

Python安装MySQLDb模块的种种问题及解决


我的环境是:Linux version 2.4.21-4.EL
(bhcompile@daffy.perf.redhat.com) (gcc version 3.2.3 20030502 (Red Hat
Linux 3.2.3-20)) #1 Fri Oct 3 18:13:58 EDT 2003 + Python2.6.4
本文结合我安装时候的问题,总结而成
用户目录如/home/liuguanyu/ , 保证用户有root权限
1,看看有没有安装
 &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号