zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    Nginx的访问控制
    远程登录
    Linux的网络命令
    laravel-collect
    laravel-model
    laravel-Macroable
    laravel-容器
    机器学习-Logisitic回归
    机器学习-多变量线性回归
    算法笔记-分支界限法
  • 原文地址:https://www.cnblogs.com/luruiyuan/p/6249438.html
Copyright © 2011-2022 走看看