python debug小技巧&&工程能力的几点建议
Debug小技巧:
转载请声明本文的引用出处:仰望大牛的小清新
1.初次编程时,在每一个if后面都写上else,这样,如果你的else原本是不应该运行的,那么就可以在else中输出此时的状态信息便于排查bug
2.不要嵌套太多的if(比如超过2层),因为嵌套多意味着需要来回查看不同层次的条件,尝试用一层if来做
3.像对待段落一样对待if-else,在它们开头和结尾加上空行,而把if-elif-else看作段落中的句子
4.if中的bool表达式应尽量简洁,如果态复杂,就用变量保存起来,并且给变量起个好名字
WARNING:Never be a slave to the rules in real life. For training purposes, you need
to follow these rules to make your mind strong, but in real life sometimes these rules
are just stupid. If you think a rule is stupid, try not using it.
关于调试和编程:
1.Make sure parts of your programs work as you work on them. Do not write massive files
of code before you try to run them. Code a little, run a little, fix a little.
关于工程能力:
One final word of advice: All programmers become paralyzed by irrational fear starting a new
large project. They procrastinate to avoid contronting this fear and end up not getting their pro-
gram working or even started. I do this. Everyone does this. The best way to avoid this is to make
a list of things you should do and then do them one at a time.
Just start doing it, do a small version, make it bigger, keep a list of things to do, and do them.
2.The best way to debug a program is to use print to print out the values of variables at
points in the program to see where they go wrong.
python debug小技巧&&工程能力的几点建议的更多相关文章
- Python学习小技巧之列表项的排序
Python学习小技巧之列表项的排序 本文介绍的是关于Python列表项排序的相关内容,分享出来供大家参考学习,下面来看看详细的介绍: 典型代码1: data_list = [6, 9, 1, ...
- 30个有关Python的小技巧,给程序员的 30 个基本 Python 贴士与技巧
30个有关Python的小技巧 2013/07/04 · Python, 开发 · 4 评论 · Python 分享到: 66 本文由 伯乐在线 - Kevin Sun 翻译.未经许可,禁止转载!英文 ...
- Python编码小技巧分享【新手必学】
本次分享了python编程小技巧总结如下,希望对大家有帮助,非常实用哦注意:很多人学Python过程中会遇到各种烦恼问题,没有人帮答疑.为此小编建了个Python全栈免费答疑交流.裙 :一久武其 ...
- Python Requests 小技巧总结
关于 Python Requests ,在使用中,总结了一些小技巧把,分享下. 1:保持请求之间的Cookies,我们可以这样做. import requests self.session = req ...
- eclipse debug小技巧
测试 Expressions 代码 public static void main(String[] args) { int x=100; System.out.println("----& ...
- 30个有关Python的小技巧
从我开始学习python的时候,我就开始自己总结一个python小技巧的集合.后来当我什么时候在Stack Overflow或者在某个开源软件里看到一段很酷代码的时候,我就很惊讶:原来还能这么做!,当 ...
- <转> 30 个有关 Python 的小技巧
目录[+] 1.1 拆箱 1.2 拆箱变量交换 1.3 扩展拆箱(只兼容python3) 1.4 负数索引 1.5 切割列表 1.6 负数索引切割列表 1.7指定步长切割列表 1.8 负数步长切割列表 ...
- Python(^^^^^小技巧^^^^^——不定期更新)
偶然想到的小技巧 ''' 交互中对传入函数的参数的数目进行检测 ''' def func(a,b,c): print(a,b,c) s=input(">>>>:&qu ...
- python相关小技巧整理[持续更新]
1. pdb的非常方便的debug,抛弃print吧~ 参考https://www.ibm.com/developerworks/cn/linux/l-cn-pythondebugger/ impor ...
随机推荐
- background 背景图铺满界面
background <body background="/image/1.png" style=" background-repeat:no-repeat ; b ...
- 【题解】HNOI2018寻宝游戏
太厉害啦……感觉看到了正解之后整个人都惊呆了一样.真的很强%%% 首先要注意到一个性质.位运算列与列之间是不会相互影响的,那么我们先观察使一列满足条件的操作序列需要满足什么条件.&0时,不论之 ...
- 【CF MEMSQL 3.0 C. Pie Rules】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- [链接] Linux下常见的~/.bashrc、/etc/profile、/etc/ld.so.config小科普以及caffe编译遇到的相关问题解决
由于博主设置禁止转载,这里贴一个链接,http://blog.csdn.net/u014266895/article/details/61928602,内容很有用,linux下很多软件问题都是各种路径 ...
- codeforces 799C Fountains
C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- hadoop 架构
- 布局之BFC
BFC 什么是BFC,在哪里需要用到BFC,BFC有什么规则?生成BFC有什么条件?这几个问题,我将为大家一一解释,下面我们进入正题. BFC(Block formatting context)直译为 ...
- Js+CSS3实现手风琴效果
效果截图: HTML代码: <div id="container"> <img src="images/photo01.jpg" alt=&q ...
- MVC 自定义HtmlHelper帮助类型之分页
方法一: 在项目中增加App_Code文件夹,新增一个MyHtmlper.cshtml视图文件 写入代码: @helper Pagger(int pageIndex, int pageCount) { ...
- The 2017 ACM-ICPC Asia East Continent League Final记录
首先感谢tyz学弟的麻麻-给我们弄到了名额- 然后就开始了ACM ECLFinal的玩耍,A*仙人掌可是立了flag要好好打的- 试机赛好像就全是GCJ kickstart的原题,然后AK了但是由于一 ...