First, class definition:
Copy Code code as follows:
Class
class, you can use its properties, and in fact, after you create a class, you can access its properties through the class name. If you modify its properties directly
(1) variable = A If exper else b(2) variable = (Exper and [b] or [C]) [0](2) variable = exper and B or C
The above three uses all can achieve the goal, like C language variable = exper? B:C: If the value of the Exper expression is true then
Read and write filesFirst Look at an example:
f = open (' Thefile.txt ', ' W ') #以写方式打开,
try:
f.write (' Wokao ')
finally:
f.close ()
How files are opened:
f = open (' file ', ' mode ')
' R ': Read-only (default). If the
Parse pathpath resolution relies on some of the variables defined in the OS:
os.sep-the separator between the parts of the path.
os.extsep-the delimiter between the filename and the file name extension.
The os.pardir-path represents a
Copy ()chutil.copy (source, destination)The Shutil.copy () function implements the file copy function, copying the source file into the destination folder, and two parameters are in string format. If destination is a file name, it is used as the
Bitwise operators are calculated by taking a number as a binary. The bitwise algorithms in Python are as follows:
Bitwise AND (Bitwise AND of x and Y)
& Example: 5&3 = 1 Explanation: 101 11 The same bit is only single-digit 1, so the result is 1
See examples directly:
Copy Code code as follows:
#!/usr/bin/python
#-*-Coding:utf-8-*-
From BS4 import BeautifulSoup
Html_doc = "" "
the Dormouse ' s story
the dormouse ' s story
once upon a time there were three little; and
1.1 Os.system (command)Runs the command command in a child shell and returns the exit state after the command command has finished executing. This is actually implemented using the C standard library function system (). This function needs to reopen
About the python2.x and 3.x to bring the print does not wrap the problem: Yesterday had a push text, using the end = definition, to solve the small horizontal problem, but because of the screen display problem, if the string length is too large, it
1. IteratorThe simplest example of a iterator should be an array subscript, and look at the following C + + code:
Copy Code code as follows:
int array[10];
for (int i = 0; i printf ("%d", array[i]);
The iterator works in
Classes and instancesA class is associated with an instance: A class is the definition of an object, and an instance is a "real object" that holds the specific information of the object defined in the class.
The following example shows how to
I was planning to develop a fun project last month, but there was no time. This is part of the project,
Deal with this part of the basic still poor communication. First analog mouse keyboard press release action, I use X11
This library, so to
Linux server has CentOS, fedora and so on, all pre-installed Python, version ranging from 2.4 to 2.5, and Windows type of server is mostly installed Python, so as long as the local write a script, upload to the corresponding machine, at run time
Copy Code code as follows:
#!/usr/bin/python
#coding: Utf-8
#write: JACK
#info: FTP Example
Import ftplib, socket, OS
From time to import sleep, CTime
def loginftp (self):FTPs = Ftplib. FTP ()Ftps.connect
Log files are usually generated by day, then replace the monitored log files by judging the file's date of production and the current time in the programThe program is just a simple example, monitor test1.log 10 seconds, turn to monitor Test2.log
The three-mesh operator is the ternary operator
The ternary expressions of some languages (such as Java) are as follows:
A result when a condition is true: the result of a false decision
Result=x if X
Python's ternary expression has the
1. Notepad can set-preferences-language-tab to spaces2. Editor recommended Sublime3. Data type:3.1 If there are many characters in the string that need to be escaped, you need to add a lot \ , in order to simplify, Python also allows r‘‘ ‘‘ the
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