python学习地址:
http://www.w3cschool.cc/python/python-intro.html
http://www.imooc.com/learn/177
官方文档中文站:
http://python.usyiyi.cn/
视频学习:
http://edu.51cto.com/course/course_id-527.html
文档编写:
http://zh-sphinx-doc.readthedocs.org/en/latest/contents.html
w3c分为了基础教程和高级教程。通过基础教程的学习后,再到慕课网进行实际的操作。
可以适用eclipse IDE进行代码的编写,需要下载插件pydev:
http://pydev.org/updates
使用Py2exe可以将你的python程序打包成exe。官方网站地址:
http://www.py2exe.org/
一个比较完整的例子地址:
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
如果你觉得麻烦也可以使用pyinstaller进行打包,地址:
https://github.com/pyinstaller/pyinstaller/wiki
丰富的例子程序:
http://code.activestate.com/recipes/langs/python/
类的反射使用,假设我有个模块models.py在org目录下面:
class Product():
def __init__(self,title,upc):
self.title = title;
self.upc = upc;
def display(self):
print "product title:%s upc:%s " % (self.title,self.upc)
我们在另一个模块下面反射获取他的信息,写法如下:
import sys
__import__("org.models")
pm = sys.modules['org.models']
print dir(pm)
pclass= getattr(pm,"Product")
print pclass
print type(pclass)
pobj = pclass('title','001')
print pobj
pobj.display()
输出结果:
['Product', '__builtins__', '__doc__', '__file__', '__name__', '__package__']
org.models.Product
<type 'classobj'>
<org.models.Product instance at 0x02BC22D8>
product title:title upc:001
这样就可以动态使用一个类。