In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Python object-oriented primary knowledge is what, I believe that many inexperienced people are helpless about this, this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
overview
Process-oriented: writing code from top to bottom according to business logic
Functional formula: encapsulate a certain function code into a function, so that there is no need to write it repeatedly in the future, just call the function.
Object orientation: Classifying and encapsulating functions to make development "faster, better and stronger... "
Process-oriented programming is most easily accepted by beginners. It often uses a long piece of code to implement a specified function. The most common operation in the development process is paste copy, that is, copying the previously implemented code block to the current function.
def Send mail (content)
#Send email alerts
Connect Mailbox Server
send mail
close the connection
while True:
If CPU utilization> 90%:
Send Mail ('CPU Alarms')
if hard disk usage> 90%:
Send Mail ('Hard Drive Alarms')
if memory usage> 80%:
Send Mail ('Memory Alarms')
Today we're going to learn about a new way of programming: Object Oriented Programming (OOP).
Note: Java and C#only support object-oriented programming, while python is more flexible that supports object-oriented programming and functional programming.
Create classes and objects
Object-oriented programming is a programming method, which needs to be realized by using "class" and "object". Therefore, object-oriented programming is actually the use of "class" and "object".
A class is a template, which can contain multiple functions, and some functions are implemented in the function
An instance object is an instance created from the template, through which the functions in the class can be executed
class is a keyword that indicates a class
Create an object with parentheses after the class name
ps: The first parameter of the function in the class must be self (see: Encapsulation of the three major characteristics of the class for details)
The functions defined in the class are called "methods."
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.