ZhangZhihui's Blog  

2024年7月30日

摘要: 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 阅读(13) 评论(0) 推荐(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 阅读(5) 评论(0) 推荐(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 阅读(3) 评论(0) 推荐(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 阅读(5) 评论(0) 推荐(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 阅读(4) 评论(0) 推荐(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 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: The print function can also be used to write to a file. The output of print, that is by default, sent to the screen can be redirected to an open file. 阅读全文
posted @ 2024-07-30 15:12 ZhangZhihuiAAA 阅读(7) 评论(0) 推荐(0) 编辑
 
摘要: 'r' - read mode(default) 'w' - write mode 'a' - append mode 'x' - exclusive creation We know that the mode 'r' opens an existing file for reading only 阅读全文
posted @ 2024-07-30 14:45 ZhangZhihuiAAA 阅读(4) 评论(0) 推荐(0) 编辑
 
摘要: Each module is loaded into memory only once during an interpreter session or during a program run, regardless of the number of times it is imported in 阅读全文
posted @ 2024-07-30 11:37 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: def func(s:str, i:int, j:int) -> str: return s[i:j] The parameter s is supposed to be a string, so we place a colon after the parameter name and then 阅读全文
posted @ 2024-07-30 11:17 ZhangZhihuiAAA 阅读(3) 评论(0) 推荐(0) 编辑
 
摘要: Parameters in Function Definition A. def func(name): Match by position or by name B. def func(name=value): Default argument C. def func(*args): Collec 阅读全文
posted @ 2024-07-30 11:06 ZhangZhihuiAAA 阅读(8) 评论(0) 推荐(0) 编辑