Python string common methods of operationPython string operations commonly used operations, such as string substitution, deletion, interception, copying, connection, comparison, search, segmentation, etc., the need for friends can refer to.1. Remove
Position parameter position parameter must correspond to formal parameter one by onedef # A, B is the positional parameter Print (a) Print (b) Test (+)The keyword parameter is independent of the formal parameter orderdef Test (x, y) Print (
Today, we introduce a very useful Python crawler library,--beautifulsoup4. BEAUTIFULSOUP4 's Chinese document reference URL is: http://beautifulsoup.readthedocs.io/zh_CN/v4.4.0/First use PIP to install this library, of course, also use lxml this
#Tuple Concept: An ordered set of immutable elements#the difference between a and a list is that tuple elements cannot be modified#definition#the notation of an element#(666,)t = (666,)#correct wordingt = (666)#wrong notation, parentheses as
One, the benefits of the module1, Improve maintainability2, REUSABLE3, avoid conflicting function names and variable namesSecond, the module classification
Built-in standard module (also known as standard library) execution help (' modules '
And: If the expression is not false, the value of the last expression is returned, and if the first expression is false, the value is false. (the value of this expression is returned when a false expression is encountered)Or: If both are false, the
UnitTest is the unit test framework for Python,Similar to the testng inside Java.From time import sleepFrom selenium import WebdriverImport UnitTestClass UnitTest (UnitTest. TestCase):# UnitTest class Inherits Unittest.testcase classdef setUp (self):
in order to further improve their python programming level, while strengthening their own supervision, will be from the Python advanced programming, Python Data Analysis Foundation, Python web crawler, Python-selenium automated testing and other
Variable number of arguments when function definition1 def f (*args,**myvars):2 print args3 print Myvars.items ( )4 F (1,2"Peng""China ")Output:1 (12)2 [('name'Peng '), ('Nation'' China')]an asterisk that represents the position Argument, for
1 defCalc (A, b):2res=a/b3 returnRes4 defMain ():5Money=input ('Enter how much money:')6Months=input ('A few more months:')7 Try:8res=Calc (int (money), int (months))9 exceptZerodivisionerror as E:#if the code inside the try is wrong, go
New Year, document update continue ~First, What is an operator? We have previously defined variables, which are used to store the data, and the data is stored for the operation, and the operation uses the operatorTo give a simple example 4 +5 = 9 .
Python Basic data typeThe self-band method of sequence type1. List of common methods2. Common methods of the Yuan Zu3. Common methods of strings1. List of common methodsL.append (obj) #在列表末尾添加新的对象L. Clear () #清空列表L. Copy () #复制列表, not the same
Use of Regular Expressions in python, python Regular Expressions
This article describes the symbols and methods of python regular expressions.
Findall: searches for all matches and returns the list of all combinations.Search: searches for the first
Cookie and session, cookiesessionCookie and session 1. cookie
Cookies are key-value pairs stored locally in the browser. It is included in the Response Header during transmission between the browser and the server. You can set cookies on both the
Python garbage collection mechanism and python garbage collection
There are three main Python garbage collection mechanisms. The first is to use the reference count to track and recycle garbage.For reference problems, we use the mark-clear method.
Python implements a script to remotely shut down the computer using 163 mailbox, python163
After learning Python for a week, I wrote the code very rough, just to use the 163 mailbox Remote Computer shutdown function. Send the Code directly. To run
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