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小技巧&&工程能力的几点建议的更多相关文章

  1. Python学习小技巧之列表项的排序

    Python学习小技巧之列表项的排序 本文介绍的是关于Python列表项排序的相关内容,分享出来供大家参考学习,下面来看看详细的介绍: 典型代码1:     data_list = [6, 9, 1, ...

  2. 30个有关Python的小技巧,给程序员的 30 个基本 Python 贴士与技巧

    30个有关Python的小技巧 2013/07/04 · Python, 开发 · 4 评论 · Python 分享到: 66 本文由 伯乐在线 - Kevin Sun 翻译.未经许可,禁止转载!英文 ...

  3. Python编码小技巧分享【新手必学】

       本次分享了python编程小技巧总结如下,希望对大家有帮助,非常实用哦注意:很多人学Python过程中会遇到各种烦恼问题,没有人帮答疑.为此小编建了个Python全栈免费答疑交流.裙 :一久武其 ...

  4. Python Requests 小技巧总结

    关于 Python Requests ,在使用中,总结了一些小技巧把,分享下. 1:保持请求之间的Cookies,我们可以这样做. import requests self.session = req ...

  5. eclipse debug小技巧

    测试 Expressions 代码 public static void main(String[] args) { int x=100; System.out.println("----& ...

  6. 30个有关Python的小技巧

    从我开始学习python的时候,我就开始自己总结一个python小技巧的集合.后来当我什么时候在Stack Overflow或者在某个开源软件里看到一段很酷代码的时候,我就很惊讶:原来还能这么做!,当 ...

  7. <转> 30 个有关 Python 的小技巧

    目录[+] 1.1 拆箱 1.2 拆箱变量交换 1.3 扩展拆箱(只兼容python3) 1.4 负数索引 1.5 切割列表 1.6 负数索引切割列表 1.7指定步长切割列表 1.8 负数步长切割列表 ...

  8. Python(^^^^^小技巧^^^^^——不定期更新)

    偶然想到的小技巧 ''' 交互中对传入函数的参数的数目进行检测 ''' def func(a,b,c): print(a,b,c) s=input(">>>>:&qu ...

  9. python相关小技巧整理[持续更新]

    1. pdb的非常方便的debug,抛弃print吧~ 参考https://www.ibm.com/developerworks/cn/linux/l-cn-pythondebugger/ impor ...

随机推荐

  1. BZOJ4311 向量(线段树分治+三分)

    由点积的几何意义(即投影)可以发现答案一定在凸壳上,并且投影的变化是一个单峰函数,可以三分.现在需要处理的只有删除操作,线段树分治即可. #include<iostream> #inclu ...

  2. Powershell快速入门

    Powershell快速入门 来源: https://blog.csdn.net/u011054333/article/details/72567590 https://blog.csdn.net/u ...

  3. [Leetcode] distinct subsequences 不同子序列

    Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

  4. clique 解题报告

    clique 题目描述 数轴上有 \(n\) 个点,第 \(i\) 个点的坐标为 \(x_i\),权值为 \(w_i\).两个点 \(i\),\(j\) 之间存在一条边当且仅当 \(abs(x_i-x ...

  5. [NOIP2002] 字串变换 宽搜+深度优化

    这道题硬是让我用STL水过.......而且题解里说的什么双向宽搜,交替扩展............... 这道题反正,STL用就用吧,但是状态数可以卡到千亿级别,因为这个东西是阶乘扩展的,然后我们发 ...

  6. SDOI 2009 学校食堂 状压dp

    这个题的关键处1 紧跟着他的bi个人 —— 由此得出任意一个状态都可以表示为 有第一个人没吃到饭做分隔的前面所有人已吃饭,并用1<<8表示之后的(包括他)的八个人的状态2 信息仍然是上一个 ...

  7. 在eclipse中从gitlab上面下载项目

    (1)在eclipse中 import --git--uri--输入用户名密码,下载,这个时候是在本地建立了一个本地仓库 (2)把仓库中的项目导入到eclipse的工作空间中. (3)将所需要的项目转 ...

  8. bzoj2424 [HAOI2010]订货 dp+单调性

    [HAOI2010]订货 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1311  Solved: 884[Submit][Status][Discu ...

  9. 计算1-1/x+1/x*x

    // algo1-1.cpp 计算1-1/x+1/x*x. #include<stdio.h> #include<sys/timeb.h> void main() { time ...

  10. 100个Swift必备Tips(第二版)

    100个Swift必备Tips(第二版) 新年第一天,给大家一本电子书,希望新的一年里,步步高升. GitHub