当前位置: 首页 > news >正文

001.[python学习]写在前面的

001.[python学习]写在前面的

0、多动手写写也许你所说的问题就不是问题;

1、最好的帮助文档是dir和help,如下图:

2、如果为了快速完成任务可以选择IDE,否则尽量不要依赖它,因为它的智能导致自己的无能;

3、也许有其他语言的编程基础和思想,但不要把它强加于你所写的python代码中,否则python只是个外壳的C。

    举两个例子,交换两个数字代码比较:

 

 1 >>> a = 10
 2 >>> b = 15
 3 >>> t = a
 4 >>> a = b
 5 >>> b = t
 6 >>> print a
 7 15
 8 >>> print b
 9 10
10 # 下面方法更简洁
11 >>> a = 10
12 >>> b = 15
13 >>> a, b = b, a
14 >>> print a
15 15
16 >>> print b
17 10

 

    字符串逆序代码比较:

 1 >>> s = 'What Are Words'
 2 >>> s2 = ''
 3 >>> for c in s:
 4 ...   s2 = c + s2
 5 ...
 6 >>> print s2
 7 sdroW erA tahW
 8 # 第二种方法
 9 >>> s = 'What Are Words'
10 >>> print s[::-1]
11 sdroW erA tahW

 

    万事开头难,这是第一篇,下篇先说说pep8

 

 1 >>> import this
 2 The Zen of Python, by Tim Peters
 3 
 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!

 

posted on 2016-06-04 00:42 amtoor 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/amtoor/p/5557999.html

相关文章:

  • 数据文件丢失的处理
  • Python for Infomatics 第14章 数据库和SQL应用一(译)
  • ORA-32004: obsolete and/or deprecated parameter(s) specified
  • 个人总结
  • 年终考评以后
  • NOSql之redis的学习
  • scapy-其中迭代器的实现细节
  • 初学前端犯下的错误(用于反省)
  • scapy-yield的含义和使用
  • Oracle-建表course
  • risc和cisc在嵌入式设备中的博弈
  • Adobe Unity大战3D网游市场
  • 面向对象和类
  • Autodesk收购引擎开发商Wild Pocket将推网页3D游戏引擎
  • 游戏将是21世纪最强大的媒体?
  • 【Under-the-hood-ReactJS-Part0】React源码解读
  • 【干货分享】SpringCloud微服务架构分布式组件如何共享session对象
  • Brief introduction of how to 'Call, Apply and Bind'
  • CentOS7简单部署NFS
  • laravel 用artisan创建自己的模板
  • Netty+SpringBoot+FastDFS+Html5实现聊天App(六)
  • Nginx 通过 Lua + Redis 实现动态封禁 IP
  • PHP 程序员也能做的 Java 开发 30分钟使用 netty 轻松打造一个高性能 websocket 服务...
  • scrapy学习之路4(itemloder的使用)
  • tab.js分享及浏览器兼容性问题汇总
  • Tornado学习笔记(1)
  • Vue全家桶实现一个Web App
  • 百度小程序遇到的问题
  • 前端性能优化--懒加载和预加载
  • 如何优雅地使用 Sublime Text
  • 设计模式(12)迭代器模式(讲解+应用)
  • 思否第一天
  • 为什么要用IPython/Jupyter?
  • 学习JavaScript数据结构与算法 — 树
  • FaaS 的简单实践
  • 如何正确理解,内页权重高于首页?
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
  • (2021|NIPS,扩散,无条件分数估计,条件分数估计)无分类器引导扩散
  • (论文阅读23/100)Hierarchical Convolutional Features for Visual Tracking
  • (免费领源码)python+django+mysql线上兼职平台系统83320-计算机毕业设计项目选题推荐
  • (转)AS3正则:元子符,元序列,标志,数量表达符
  • (转)重识new
  • *上位机的定义
  • .NET 8.0 中有哪些新的变化?
  • .NET Framework .NET Core与 .NET 的区别
  • .Net 中的反射(动态创建类型实例) - Part.4(转自http://www.tracefact.net/CLR-and-Framework/Reflection-Part4.aspx)...
  • .NET单元测试
  • .Net多线程总结
  • /3GB和/USERVA开关
  • @JsonFormat与@DateTimeFormat注解的使用
  • [ 云计算 | Azure 实践 ] 在 Azure 门户中创建 VM 虚拟机并进行验证
  • [C++] 如何使用Visual Studio 2022 + QT6创建桌面应用
  • [cogs2652]秘术「天文密葬法」
  • [Django ]Django 的数据库操作