wenwen
wenwen

探索網路世界和進入區塊鏈的過程或許很平凡,但我就是想分享給大家,若能幫助到有需要幫助的人,那就更好了。 有幫到你的話,記得按下方拍手圖,不需花你任何金錢,免費註冊Liker ID,就可對我化讚為賞:https://button.like.co/willie5068

015第九章 CLASSES_續3_The Python Standard Library

終於看完 第九章 CLASSES 了

💛20230115晨讀感言:

💔這句話解釋了為什麼會使用到 import :Sometimes you’ll want to spread out your classes over several modules ==to keep any one file from growing too large and avoid storing unrelated classes in the same module==.

💔得知 [The Python standard library](https://docs.python.org/3/library/index.html) ,既然我已學了 import 的運用,那麼,上面這個 library 裡面的 modules 等 資訊 絕對能夠在我寫 程式時 提供大量的支持。

💔在使用 [The Python standard library] 裡的 modules 時,你會發現 improt 的「對象」,不見得是 ==開頭大寫 的 Class==,有可能是 ==開頭小寫的 function==。而這也讓我聯想到之前學 Functions 裡也有使用 modules ,並運用 import 方式 載入到 你的程式中 運用。

💔==只要使用 improt 的「對象」,就可以 在 對象 的後面 加上() 來 呼叫 function 或 完成建置 Class 的 instance ==。結論: 對象 的開頭是大寫的 Class 時,才能稱之 完成建置 該 對象 的 inctance ,即 「 對象() 」,否則,就只是 單純 地 呼叫 function 來使用。

💛晨讀摘要:

💚178 If you need to import many classes from a module, you’re better off importing the entire module and using the _module_name_._class_name_ syntax.

💚180 The Python Standard Library: [The Python standard library] is a set of modules included with every Python installation. Now that you have a basic understanding of how functions and classes work, you can start to use modules like these that other program- mers have written. You can use any function or class in the standard library by including a simple import statement at the top of your file. Let’s look at one module, random, which can be useful in modeling many real-world situations.

💚181 Styling Classes: Class names should be written in _CamelCaps_. To do this, capitalize the first letter of each word in the name, and **don’t use underscores.** Instance and module names should be written in lowercase with underscores between words.

💚Within a class you can use one blank line between methods, and within a module you can use two blank lines to separate classes.

💚If you need to import a module from the standard library and a module that you wrote, place the import statement for the standard library module **first**. Then add a blank line and the import statement for the module you wrote.

from :《python crash course》

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…
加载中…

发布评论