用python的人,好象在做桌面程序的时候,都会有说用wxwidgets,在网上搜了很久,好象都是在推荐这个。。。
wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module (native code) that wraps the popular wxWidgets cross platform GUI library, which is written in C++.
Like Python and wxWidgets, wxPython is Open Source which means that it is free for anyone to use and the source code is available for anyone to look at and modify. Or anyone can contribute fixes or enhancements to the project.
wxPython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification. Currently supported platforms are 32-bit Microsoft Windows, most Unix or unix-like systems, and Macintosh OS X.
Since the language is Python, wxPython programs are simple, easy to write and easy to understand. Here is an example.
上面的内容纯粹是介绍,但是我还处于初学阶段,关键没时间折腾啊,哎。真痛苦。还好wxPython上还有一些使用的介绍,就是那个How to Learn wxPython,有很多介绍。
说来也郁闷,装了一个aptana3,却找不到怎么创建python的工程,这让我想起了komodo edit,好象就直接支持python了。。。看来越是大的东西,越比较让人难以使用。目前在WIN下,好象官方的wiki介绍的IDE也不少。。。有空下载了玩玩。列表在这里:http://wiki.python.org/moin/PythonEditors#Windows-OnlyEditors
极有意思的网站,比较适合我们这些初学者,当然是对PHP有一些基础的初学者
网站主把常用的一些PHP的函数,用Python实现了一遍(或者是显示Python的自有函数),方便我们查找例子
例如:PHP常用的addslashes函数,用来对特殊字符进行转义,
该网站则显示:
http://www.php2python.com/wiki/function.addslashes/
- def addslashes(s):
- d = {'"':'\\"', "'":"\\'", "\0":"\\\0", "\\":"\\\\"}
- return ''.join(d.get(c, c) for c in s)
-
- s = "John 'Johny' Doe (a.k.a. \"Super Joe\")\\\0"
- print s
- print addslashes(s)
-
-
实现方法虽然有点不一样,但对于我们这些初学者已经了解了很多用法,比如for in,join ,dict的get用法。当然还有定义函数的def方法。
这个网站是什么呢?http://www.php2python.com,黑黑,已经加入我的收藏夹了。感谢小缘缘的推荐
初学python,小缘缘出了几道题:
有一 list
a = [1, 2, 3, 4, 5, 6]
請將 a 依
0, 1
1, 2
2, 3
3, 4
4, 5
5, 6
打印輸出,
2.將a list 倒序成 [6, 5, 4, 3, 2, 1]
3.將a 中的偶數挑出 *2 ,結果為 [4, 8, 12]
基本上实现:
a=[1,2,3,4,5,6]
for i in a:
print a.index(i),',',i
a.reverse();
print a
for i in a:
if i%2==0
print i*2
虽然都完成了,但小缘缘说回答的不好,他这样回复
for k,v in enumerate(a):
print k,v
print a[::-1]
print [i*2 for i in a if not i%2]
当时我就傻眼了,后来缘缘又出了道题目:
造一個 200 個隨機正整數(1~15)的list
統計其中 正整數的出現次數,並排序輸出結果
开始的时候,不清楚random居然还要import。。。。
后来花了好久做出来:
>>> import random
>>> mylist = [random.randint(1,15) for i in range(1,200)]
>>> s={}
>>> for i in mylist:
if not s.has_key(i):
s[i]=0
else:
s[i]+=1
>>> cmplist = sorted(s.items(),key=lambda(d):d[1])
>>> result = cmplist[::-1]
>>> print result
[(8, 20), (13, 19), (12, 16), (9, 15), (6, 15), (3, 14), (2, 12), (14, 11), (4, 11), (15, 10), (7, 10), (11, 9), (5, 9), (1, 9), (10, 4)]
缘缘点评循环的时候,可以用Get比如
for i in mylist:
s[i]=s.get(i,0)+1
然后说sorted可以有从大到小的倒排,后来找了一下资料,发现可以这样
sorted(d.items(),cmp=lambda x,y:cmp(x[1],y[1]),reverse=True)
第一次写python,鸭梨太大了。。。