作家
登录

几个小例子告诉你, 一行Python代码能干哪些事

作者: 来源: 2017-10-26 14:24:26 阅读 我要评论

沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散!


起首你要懂得一下Python之禅,一行代码输出“The Zen of Python”:

  1. python -c "import this"  
  2. "" 
  3. The Zen of Python, by Tim Peters  
  4. Beautiful is better than ugly.  
  5. Explicit is better than implicit.  
  6. Simple is better than complex.  
  7. Complex is better than complicated.  
  8. Flat is better than nested.  
  9. Sparse is better than dense.  
  10. Readability counts.  
  11. Special cases aren't special enough to break the rules.  
  12. Although practicality beats purity.  
  13. Errors should never pass silently.  
  14. Unless explicitly silenced.  
  15. In the face of ambiguity, refuse the temptation to guess.  
  16. There should be one-- and preferably only one --obvious way to do it.  
  17. Although that way may not be obvious at first unless you're Dutch.  
  18. Now is better than never.  
  19. Although never is often better than *right* now.  
  20. If the implementation is hard to explain, it's a bad idea.  
  21. If the implementation is easy to explain, it may be a good idea.  
  22. Namespaces are one honking great idea -- let's do more of those!  
  23. ""

大年夜“The Zen of Python”也能看出,Python倡导Beautiful、Explicit、Simple等原则,当然我们接下来要介绍的一行Python能实现哪些好玩的功能,可能和Explicit原则相违背。

几个小例子告诉你, 一行Python代码能干哪些事

如不雅你有其他这方面的小例子,也迎接评论,我会加到文┞仿中,文┞仿也许会经久更新。

  1. python -m SimpleHTTPServer 8080 # python2 
     1/4    1 2 3 4 下一页 尾页

      推荐阅读

      大数据真的在云计算上的快车上吗?

    沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散!软件始创厂商AtScale公司客岁事尾宣布了其年度大年夜数据成熟度查询拜访申报(页堪财为“Hadoop成熟度查询拜访&rdquo>>>详细阅读


    本文标题:几个小例子告诉你, 一行Python代码能干哪些事

    地址:http://www.17bianji.com/lsqh/38257.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)