博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python debug小技巧&&工程能力的几点建议
阅读量:6485 次
发布时间:2019-06-23

本文共 1315 字,大约阅读时间需要 4 分钟。

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.

 

转载于:https://www.cnblogs.com/luruiyuan/p/6249438.html

你可能感兴趣的文章
没有用过苹果的来了解一下mac的强悍吧
查看>>
查询条件中sum和group by的比较
查看>>
我的友情链接
查看>>
linux下ssh安全连接
查看>>
Linux系统是否被植入***的排查流程梳理
查看>>
OpenWRT路由固件在VMware、vShpere虚拟机中运行操作
查看>>
oracle执行update时卡死问题
查看>>
ChemDraw Pro绘制无环链结构的两种方法
查看>>
几何画板使用方法
查看>>
【LeetCode刷题】SQL-Second Highest Salary 及扩展以及Oracle中的用法
查看>>
linux 下 MySQL源码包的安装
查看>>
$.each() each
查看>>
Linux获取进程执行时间
查看>>
<转>SQL Server返回最后一个标识值的三个函数:IDENT_CURRENT、@@IDENTITY、SCOPE_IDENTITY...
查看>>
文件与文件系统的压缩与打包命令
查看>>
mysql命令
查看>>
MySQL通配符与正则表达式
查看>>
linux下修改tomcat内存大小
查看>>
windows下安装redis(转载)
查看>>
php不常用而又实用的函数
查看>>