Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[译] [502] 本章小结 #18

Open
cssmagic opened this issue Feb 29, 2024 · 0 comments
Open

[译] [502] 本章小结 #18

cssmagic opened this issue Feb 29, 2024 · 0 comments

Comments

@cssmagic
Copy link
Owner

Summary

本章小结

  • A loop is used to repeat code as many times as needed.
  • We use a for loop when we know how many iterations the loop will do; we use a while loop when we don’t know how many iterations a loop will do.
  • Python uses indentation to determine which lines of code go together.
  • A dictionary is a mapping from keys (such as words) to values (such as their frequencies).
  • We need to open a file before we can read from it.
  • Once a file is open, we can use methods or a loop to read its lines.
  • Some modules (such as csv and zipfile) come with Python and can be used by importing them.
  • Other modules, such as matplotlib, need to be installed first before they can be imported and used.
  • 循环用于根据需要重复执行代码多次。
  • 当我们明确知道循环将执行的迭代次数时,使用 for 循环;而在不确定循环将执行多少次迭代时,则采用 while 循环。
  • Python 通过缩进来判断哪些代码行应该组合在一起。
  • 字典是从键(例如单词)到值(例如它们的频率)的映射。
  • 我们必须先打开一个文件,才能开始从中读取数据。
  • 文件打开后,我们可以使用方法或循环来逐行读取。
  • 一些模块(如 csv 和 zipfile)是 Python 自带的,可以直接通过导入来使用。
  • 其他模块,例如 matplotlib,需先安装之后才能导入和使用。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant