python性能增强工具shedskin 0.3版发布
http://code.google.com/p/shedskin/ Shed Skin 0.3 - support for 3 new standard library modules (now about 20 in total): - itertools (jeremie roquet) - heapq (jeremie roquet) - csv (converted using shedskin) - 4 new example programs (now 44 in total!): - maximum weighted matching algorithm (joris van rantwijk) - kanoodle: knuth's dancing links (david austin) - bidirectional dijkstra algorithm (from networkx, uses heapq) - barnes-hut force calculation - improved type inference (scalability, bugfixes, major cleanup) - support for 'map', 'filter', 'reduce' and 'next' - support for 'with' statement (jeremie roquet) - support for 'key' argument of 'sorted' (and 'list.sort') - reorganized codebase, distutils setup.py (thomas spura) - optimized list indexing (joris van rantwijk) - optimized addition of 1-length lists and strings - improved forward referencing of variables/functions - avoid GCC warnings after 'shedskin -e' - support for passing keyword arguments to extension modules - optimized list slicing - ignore blocks surrounded by #{ and #} (mike schrick) - add --makefile option (mike schrick) - several cleanups, removing about 100 lines again - large amount of bugfixes
相关文档:
这是一个我们在处理中文时, 经常遇到的问题.
python里面基本上要考虑三种编码格式
1 源文件编码
在文件头部使用coding声明。告诉python解释器该代码文件所使用的字符集。
#/usr/bin/python
#coding: utf8
2 内部编码
代码文件中的字符串,经过decode以后,被转换为统一的unicode格式的内部数据,类似于u'*'。unic ......
import random def windex(lst):
'''an attempt to make a random.choose() function that makes weighted choices
accepts a list of tuples with the item and probability as a pair'''
wtotal = sum([x[1] for x in lst])
......
writeblog.csdn.net writeblog.csdn.net/PostEdit.aspx
这个程序很早以前就写过了,而且是参考的别人的写,具体谁的发在哪里我都忘记了。这里就算是半原创了,如有侵权请及时通知改正。
因为从今天1月1号开始,Google上订阅的天气预报服务已经取消了,估计是Google被施加压力了。反正是收不到天气预报了。正好重拾以前 ......
Python已经是3.1版本了,与时俱进更新教程.
本文适合有Java编程经验的程序员快速熟悉Python
本文程序在windows xp+python3.1a1 测试通过.
本文提到的idle指python shell,即安装python后你在菜单看到的IDLE(python gui)
在idle里ctrl+n可以打开一个新窗口,输入源码后ctrl+s可以保存,f5运行程序.
凡打开新窗口即指ctrl ......