the characteristics of Python
1. Simple
Python is a language that represents simple ideas.
2. easy to learn
Python has an extremely simple syntax.
3. free, open source
Python is one of the floss (free/open source) software.
4. high-level language
Using
Describes the basic syntax of Python crawlers and python crawlers.
What is crawler?
Crawlers, that is, web crawlers, can be understood as crawlers that have been crawling on the Internet. The Internet is like a large network, and crawlers are crawlers that have crawled on the Internet, if it encounters a resource, it will capture it. What do you want to capture?
sorted as if each comparison were reversed. In general, the key and reverse conversion processes is much faster than specifying anEquivalent CMP function. This is because CMP are called multiple times for each list element while keys and reverse touch each element only once.L5 = [10, 5, 20, 1, 30]L5.sort ()Print L5 #[1, 5, 10, 20, 30]L6 = ["BCD", "abc", "CDE", "BBB"]L6.sort (cmp = lambda S1, s2:cmp (s1[0],s2[1]))Print L6 #[' abc ', ' BBB ', ' BCD ',
Learning a development language first of course is to be familiar with its grammar, Python syntax is relatively simple, here from the basics of the beginning to understand.Identifier1. The first character must be a letter in the alphabet or an underscore ' _ '.2. The other parts of the identifier are composed of letters, numbers, and underscores.3. Identifiers are case sensitive.Reserved wordsReserved words
mechanism. python can use _ getattr _ to intercept undefined methods (from Qiezi) 13. Ruby uses single inheritance + Mixin, and python uses multiple inheritance, but Python also has Mixin 14. Ruby has the ATTR _ * series syntax helper, saving you the trouble of writing a bunch of setter/getter. The
I hope this article can help you through the Python interview, and then there is a Python web-related article to welcome everyone to read.
1. What is the function of the pass statement in Python?Pass statement does nothing, generally as a placeholder or create a placeholder, the pass statement will not do anything.
2.
beginning of a new piece of code. The class and function entries are also separated by a line of blank lines to highlight the beginning of the function entry.Blank lines are different from code indentation, and empty lines are not part of the Python syntax. When you write without inserting a blank line, the
;
}
mysql_insert_id
After adding a message using the Insert command, you can use this function to obtain the unique ID of the newly added record
Grammar
int mysql_insert_id ([esource Link_identifier])
eg
Copy Code code as follows:
$DB _host = "localhost";
$DB _login = "root";
$DB _password = "123456";
$DB _name = "Flag";
$conn =mysql_connect ($DB _host, $DB _login, $DB _password);
mysql_select_db ($DB _name);
$
Python indent syntax, advantages and disadvantages, python indent
Python syntax is relatively simple-indent
Indentation has the following advantages:
One of the advantages is to force you to write formatted code, but there is no rule on whether the indentation is a few
After learning about the basics of Python, how can I find small projects to learn? Which website communities have more resources? After learning about the basics of Python, how can I find small projects to learn? Which website communities have more resources? Reply: Thank you @ Zhuangzhuang demon. I think this is not enough to write a program. Even if I look at it, I can only stay at the level of a small sc
can be composed of multiple lines, writing the shortcut syntax of multiple lines of text, common language file strings, at a specific location of the file, as a comment.Word = ' word ' sentence = "This is a sentence." Paragraph = "" "This is a paragraph. It ismade up of multiple lines and sentences. "" " Python commentsA single-line comment in Python starts wit
variables to the class definition, but add them dynamically at run time.The Python class provides something like the C # constructor: __init__ (note that there are two underscores before and after), the class will call this function first when instantiated, and we can do the initialization of variables by overriding the __INIT__ function. Unlike C #,
, the key and reverse conversion processes is much faster than specifying anEquivalent CMP function. This is because CMP are called multiple times for each list element while keys and reverse touch each element only once.L5 = [10, 5, 20, 1, 30]L5.sort ()Print L5 #[1, 5, 10, 20, 30]L6 = ["BCD", "abc", "CDE", "BBB"]L6.sort (cmp = lambda S1, s2:cmp (s1[0],s2[1]))Print L6 #[' abc ', ' BBB ', ' BCD ', ' CDE ']L7 = ["BCD", "abc", "CDE", "BBB", "FAF"]L7.sort
String
The single and double quotation marks in Python are used exactly the same.
Use the quotation marks ("' or" ") to specify a multiline string.
Escape character ' \ '
Natural string, by adding R or R before the string. such as R "This was a line with \ n \" will be displayed, not newline.
Python allows processing of Unicode strings, prefixed with u or u, such as u "This is
Tags:%s pre definition multiple boot failures # # hint lock### One, data type Python's basic data types are numeric, string, Boolean Binary format output Placeholder%s STR %d int %f float Specification for three-variable definitions Hump Method Oldboy Underline method Old_boy Variables can have numbers, letters, underscores, but cannot start with numbers Four single quotes, double quotes, three quotes. Single and double quotes are no different, but cannot be mixed When three quotes are used for
are prefixed with an object. The private variable and private method of the class are prefixed with two underscores.(3) The function name is usually lowercase, with an underscore or the first letter capitalized to increase the readability of the name, and the import function is prefixed with the module name.2, code indentation and colon code indentation refers to the way you enter spaces or tabs before ea
Note:1: variables in the python program are passed in to html using the following method::
1: using global variables: global variables do not need to be passed using the $ def with syntax, as long as they are defined
It can be used in html, for example:========================================================== ======================================
# Template public variables. The following can define t
its original format# loads (string) restores the object, and the object type reverts to its original format newscorelist=print newscorelistThe output result ishas been restored to its original③ storing objects inside a file serializationStudents= (" Zhang San "," John Doe "," Harry " , " Zhao Liu ") file1=file ("back.pkl"," WB " ) Pickle.dump (students,file1,true) file1.close ()After execution, the file directory list has one more file:Open the file with the following contents:④ dump () data st
statement.But we can use a slash (\) to divide a line of statements into multiple lines of display, as follows:=+ + item_three The statement contains [], {}, or () parentheses do not need to use a multiline connector. The following example:=[' Monday ',' Tuesday ',' Wednesday ',' Thursday ', ' Friday ']Python QuotesPython receives single quotation marks ('), double quotation marks ("), and three quotation marks (" ' "" ") to denote the str
" ") to specify a multiline string.
Escape character ' \ '
Natural string, by adding R or R before the string. such as R "This was a line with \ n \" will be displayed, not newline.
Python allows processing of Unicode strings, prefixed with u or u, such as u "This is a Unicode string".
The string is immutable.
The literal cascading string, such as "This" and "is" and "string", is automatically converted to this is string.
=' s
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.