Python 简介Python历史Python的创始人为荷兰人吉多·范罗苏姆Guido van Rossum。1989年的圣诞节期间吉多·范罗苏姆为了在阿姆斯特丹打发时间决心开发一个新的脚本解释程序作为 ABC 语言的一种继承。之所以选中Python作为程序的名字是因为他是 BBC 电视剧——蒙提·派森的飞行马戏团Monty Pythons Flying Circus的爱好者。1991年第一个 Python 编译器诞生。它是用C语言实现的并能够调用C语言的库文件。Python 2.0于 2000 年 10 月 16 日发布增加了实现完整的垃圾回收并且支持Unicode。Python 3.0于 2008 年 12 月 3 日发布此版不完全兼容之前的Python源代码。不过很多新特性后来也被移植到旧的Python 2.6/2.7版本。第一行Python代码安装好Python之后在命令行下输入python就可以进入Python解释器的页面。按照惯例第一行代码应该是输出hello world!printhello world!hello world!相对与JavaC等语言Python仅仅使用一行语句就完成的了这个任务。可以将这句话的内容保存到一个文本文件中并使用后缀名.py结尾例如hello_world.py在命令行下运行这个程序python hello_world.py也会输出hello world!的结果。Python 之禅在Python解释器下输入import this会出来这样一首小诗importthisThe Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases arent special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless youre Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, its a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- lets do more of those!这首诗反映了Python的设计哲学——Python是一种追求优雅明确简单的编程语言但事实上产生这首诗的代码并没有写的那么简单易懂sGur Mra bs Clguba, ol Gvz Crgref Ornhgvshy vf orggre guna htyl. Rkcyvpvg vf orggre guna vzcyvpvg. Fvzcyr vf orggre guna pbzcyrk. Pbzcyrk vf orggre guna pbzcyvpngrq. Syng vf orggre guna arfgrq. Fcnefr vf orggre guna qrafr. Ernqnovyvgl pbhagf. Fcrpvny pnfrf nerag fcrpvny rabhtu gb oernx gur ehyrf. Nygubhtu cenpgvpnyvgl orngf chevgl. Reebef fubhyq arire cnff fvyragyl. Hayrff rkcyvpvgyl fvyraprq. Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff. Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg. Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbher Qhgpu. Abj vf orggre guna arire. Nygubhtu arire vf bsgra orggre guna *evtug* abj. Vs gur vzcyrzragngvba vf uneq gb rkcynva, vgf n onq vqrn. Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. Anzrfcnprf ner bar ubaxvat terng vqrn -- yrgf qb zber bs gubfr!d{}forcin(65,97):foriinrange(26):d[chr(ic)]chr((i13)%26c)print.join([d.get(c,c)forcins])The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases arent special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless youre Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, its a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- lets do more of those!Life is short. Use Python.