摘要:
There are many built-in functions and methods that return iterables and iterators. Here are a few examples: range() returns an iterable dict.keys() re
阅读全文
posted @ 2024-07-31 09:43
ZhangZhihuiAAA
阅读(20)
推荐(0)
摘要:
class Engine: def __init__(self,power): self.power = power def start(self): self.draw_current() self.spin() self.ignite() def draw_current(self): prin
阅读全文
posted @ 2024-07-31 09:34
ZhangZhihuiAAA
阅读(16)
推荐(0)
摘要:
We have seen that if we have to define a group of classes that have similar features and show common behavior, we can define a base class and then inh
阅读全文
posted @ 2024-07-31 09:30
ZhangZhihuiAAA
阅读(23)
推荐(0)
摘要:
The three main features of object-oriented programming are - encapsulation, inheritance and polymorphism. We have seen the first two, now let us see w
阅读全文
posted @ 2024-07-31 09:19
ZhangZhihuiAAA
阅读(34)
推荐(0)
摘要:
The order in which Python searches for attributes in base classes is called method resolution order(MRO). It gives a linearized path for an inheritanc
阅读全文
posted @ 2024-07-30 22:07
ZhangZhihuiAAA
阅读(54)
推荐(0)
摘要:
The magic methods __str__ and __repr__ are used for converting an instance object into a string. The method __str__ is invoked when an instance object
阅读全文
posted @ 2024-07-30 20:42
ZhangZhihuiAAA
阅读(21)
推荐(0)
摘要:
Creating Managed Attributes using properties Properties can be used to create data attributes with special functionality. If you want some extra funct
阅读全文
posted @ 2024-07-30 18:55
ZhangZhihuiAAA
阅读(24)
推荐(0)
摘要:
Sometimes we have to write methods that are related to the class but do not need any access to instance or class data for performing their work. These
阅读全文
posted @ 2024-07-30 18:29
ZhangZhihuiAAA
阅读(43)
推荐(0)
摘要:
Class methods allow us to define alternative initializers (also known as factory methods) in a class. These methods help us create instance objects fr
阅读全文
posted @ 2024-07-30 16:32
ZhangZhihuiAAA
阅读(37)
推荐(0)
摘要:
os.getcwd() Returns the path of the current working directory os.chdir(path) Changes our current working directory
阅读全文
posted @ 2024-07-30 15:49
ZhangZhihuiAAA
阅读(18)
推荐(0)