cssmagic / Learn-AI-Assisted-Python-Programming

📖 《AI 辅助编程》这本书的大本营。
140 stars 14 forks source link

[译] [800] 第八章 调试代码并且更深入地理解代码 #14

Open cssmagic opened 8 months ago

cssmagic commented 8 months ago

8 Debugging and Better Understanding Your Code

第八章 调试代码并且更深入地理解代码

This chapter covers

本章内容概要

There will be a point in every programmer’s career when their code isn’t doing what they want it to do. This has likely happened to you already, and, rest assured, it is a normal part of learning to program. How do we fix the code? Sometimes, changing the prompt or better decomposing the problem like you learned in earlier chapters is sufficient to fix the problem. But what do you do when you just can’t get Copilot to give you different or better code, and you can’t seem to figure out why the code you’ve been given doesn’t work properly?

在每位程序员的职业道路上,都会遇到代码不按他们所愿执行的时刻。这很可能已经发生在你身上,而且,请放心,这是学习编程过程中的一部分。我们如何修正代码?有时,改变提示词或者如前几章所学,更精确地分解问题就足以解决问题。但是,当你无法让 Copilot 提供不同或更好的代码,又或者无法搞清楚为什么你得到的代码不能正常工作时,你应该怎么办?

This chapter serves two purposes. The primary goal is to learn how to find errors (called bugs) in the code and fix them. To find those bugs, you’ll need to fulfill the second goal, which is gaining a deeper understanding of how your code works while you are running it.

本章节的目标有二。首要任务是学习如何发现代码中的错误(俗称 bug)并予以修复。而为了找到这些错误,你还需实现第二个目标,那就是在代码执行时深入理解其运作原理。

The good news is that having an error in your code is such a common occurrence for programmers that programming environments, like Visual Studio Code (VS Code), have tools to help us uncover what is going wrong. We’ll learn how to use that tool, called a debugger, in this chapter as well.

值得庆幸的是,代码出现错误对编程人员来说极为常见,以至于像 Visual Studio Code(VS Code)这种编程环境都配备了工具来帮助我们找出问题所在。本章我们将学习如何使用这种称为调试器的工具。

...

...


本章目录


本章正文略。如需阅读,请购买正版。


cssmagic commented 3 months ago

👉 想要更多译稿预览,请前往 总目录 中按章节阅读。