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
相关文档:
这是一个简单的表达式计算器, 不太懂用Tkinter写GUI, 参考了别人的代码
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pa ......
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被施加压力了。反正是收不到天气预报了。正好重拾以前 ......
1 遍历文件夹和文件
import os
import os.path
# os,os.path里包含大多数文件访问的函数,所以要先引入它们.
# 请按照你的实际情况修改这个路径
rootdir = " d:/download "
for parent, dirnames, filenames in os.walk(rootdir):
  ......