Reason:
Yes, you should assign all attributes of your object in the __init__ method.
The most important reason to does this are tool support. Many Python IDEs can see the assignments in the and use __init__ those attributes for
A list of lists.L = [' aaa ', ' BBB ', 89]A list is an ordered set of mathematical meanings, that is, the elements in the list are arranged in order.Check:How do I get the nth data from a list? The method is to get the specified element in the list
9.1 File Operation Flow1. Open the file, get the file handle and assign a value to a variable2. Manipulating files with a handle3. Close the file9.2 file read-write and close operation#! Author:lanhan#data = open ("Yesterday", encoding= "Utf-8").
1.os:linux (CENTOS7)2. Specific operation:[[email protected] ~]$ sudo pip uninstall python[sudo] password for sdmowner: ( Enter the user secret code )Deprecation:uninstalling a distutils installed project (python) has been deprecated and'll be
name=['Liutao','Chuyunfei','Qifei','Xianmoumou']#Define a list#AddName.append ('123')#appends an element at the end of the list with only one additionalName.insert (1,'Liutao2')#you can add elements anywhere in the list, but the previous one is the
#! Author:lanhanName ="My\ tname is {name} and I ' {year} old 'Print (Name.capitalize ())#首字母大写Print (Name.count ("a"))#统计a出现次数Print (Name.center (50,"-"))#字符串在中间, both sides--paddedPrint (Name.endswith ("Han"))#判断字符串是否以 Han EndPrint
4.1 Standard librarylibraries that do not need to be installed, directly imported (path: E:\\autopython\\softinstall\\python3.6.3\\lib)4.1.1 Sys moduleExample 1:#! Author:lanhanImport sys#print (Sys.path) # # #打印环境变量Print (SYS.ARGV) # #
Callback mechanismImport requestsRequires support for requests modulesscenario where a callback function is required: once any of the tasks in the process pool have been processed, inform the main process immediately: I'm all right, you can handle
A python tuple is similar to a list, except that the elements of a tuple cannot be modified.Tuples use parentheses, and the list uses square brackets.1, the definition of the tupleTuple1 = ("Hello"," World", 100, 200) Tuple2= ()#define an empty
The first step is to install Python first, and the version selected by blogger is the latest version of 3.4.2. The Python installation under Windows is typically installed through the software installation package instead of the command line, so
Set set is an unordered and non-repeating collection of elementsThis data type is not duplicated, and there is no orderSome basic methods:adding elementsS1 = {One, all,}s1.add (123)# Add a new element print(s1) {123, 33, 11, 22}Clear content:S1 =
Locating a group of objectsLocate a group of objects--find_elements_by_ ... (), note, here is elements, plural. The returned result is a list of values that we need to use to get the elements we want. There is so much to be aware of. See a piece of
Blog Application Project (detailed operations), blog details
1. cookie and sessionCookie can work independentlyCookie can also be used with sessionEach browser has a cookie :{}When the browser first accesses the server, the cookie is empty.The
Python configuration file,
As we all know, applying the configuration file during our development process is a convenient choice for us. When we do not need to modify it frequently and the data volume is small, we can select a configuration file to
Python was taught on the first day, variables, basic data types, and python on the first day
PyCharmSome simple and common settingsSet TemplateFile-> Settings-> Editor-> File and Code Templates
// Switch the python versionFile-> settings-> Project
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service