手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表分类:python

wxPython

用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

Tags: wxpython, wxwidgets

Python学习资源

学习Python的时候,还是翻了一些资料,也看到了一些资源。收集着,以后慢慢看。

http://woodpecker.org.cn/abyteofpython_cn/chinese/index.html
嗯,http://woodpecker.org.cn/,这个网上有很多Python的资源哦。
然后在这个网站还有这些链接哦

都挺不错。也几乎点开看了。。相对于这个,我其实更喜欢这样的CHM文件,

这两个链接里,可是有CHM文件下载的哦。

Tags: python

php2python

极有意思的网站,比较适合我们这些初学者,当然是对PHP有一些基础的初学者
网站主把常用的一些PHP的函数,用Python实现了一遍(或者是显示Python的自有函数),方便我们查找例子

例如:PHP常用的addslashes函数,用来对特殊字符进行转义,

该网站则显示:

http://www.php2python.com/wiki/function.addslashes/
  1. def addslashes(s):  
  2.     d = {'"':'\\"', "'":"\\'", "\0":"\\\0", "\\":"\\\\"}  
  3.     return ''.join(d.get(c, c) for c in s)  
  4.   
  5. s = "John 'Johny' Doe (a.k.a. \"Super Joe\")\\\0"  
  6. print s  
  7. print addslashes(s)  
  8. #John 'Johny' Doe (a.k.a. "Super Joe")\  
  9. #John \'Johny\' Doe (a.k.a. \"Super Joe\")\\\  

实现方法虽然有点不一样,但对于我们这些初学者已经了解了很多用法,比如for in,join ,dict的get用法。当然还有定义函数的def方法。

这个网站是什么呢?http://www.php2python.com,黑黑,已经加入我的收藏夹了。感谢小缘缘的推荐

Tags: php, python, function

初学python

初学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,鸭梨太大了。。。

Tags: python, import, random

Records:912