This article mainly introduces the basic introduction of Python, including file input/output, built-in type, dictionary operation and other ways to useI. Variables and expressionsThe code is as follows:>>> 1 + 12>>> print ' Hello World 'Hello World>>
Coding problem has always been a headache problem:when the string is: ' \u4e2d\u56fd '>>>s=[' \u4e2d\u56fd ', ' \u6e05\u534e\u5927\u5b66 ']>>>str=s[0].decode (' Unicode_escape ') #.encode ("Euc_kr")>>>print StrChinaWhen the string is: ' & #19996;& #2
Using Python to make a web-capture program is very fast, here's an example:Import= Urllib2.urlopen ('http://blog.raphaelzhang.com'). Read ()But in the actual work, this writing is far from enough, at least encounter the following problems:
1. Simply print the log to the screen
Import loggingLogging.debug (' This is Debug message ')Logging.info (' This is Info message ')Logging.warning (' This is warning message ') on-screen printing: WARNING:root:This is WARNING
Conditions and loopsConditional execution:Name = Raw_input (' What's your name? ' If Name.endswith (' Gumby '):p rint ' Hello, Mr.gumby 'What is your name? Gumbyhello, Mr.gumbyName = Raw_input (' What's your name? ' If Name.endswith (' Gumby '):p
Format is a new way to format a string, and it has many advantages over the older version of the python2.6 format method.1. There is no need to ignore the data type problem, in the% method%s can only replace the string type2. Single parameter can be
Today read the 40th chapter of LPTHW after the enlightened, the original has been dull, do not understand the definition and use of the class, there is not quite understand the definition of self.class MyStuff (object): def __init__ "and nowa
The connection efficiency of strings has been mentioned in the discussion of Python efficiency, and most recommend using join instead of "+" for string connectionsEverything in Python object string object is the C API stringobject.c see Python
Returns trueif all elements of an object that can iterate are true if there is one element, otherwise Falseis returned. Or the iterator object is empty and also returns False. This function is mainly used to determine whether the list, tuple,
1, JSON module introduction JSON (JavaScript Object Notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy for machine parsing and generation. It is based on JavaScript programming Language, Standard
A small example of your own writing is to convert the local TXT file to JSON format output.Data sourceSimple 1-10 Save a file, A-j save a fileImport Jsonbook = ' C:\Python27\\book.txt ' date = ' C:\Python27\date.txt ' book_list = []date_list =
Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement.The Python built-in (built-in) function is created as the Python interpreter runs. In Python programs, you can call these functions at any time, and you
A python conditional statement determines which block of code is executed by judging the execution result of one or more conditional statements.The IF statement in Python is used for control program execution in the basic form:If judging
Escape character reference table:
\ At the end of a row
Line continuation character
\\
Print a backslash
\‘
Print single quotation marks
\"
Print double quotation marks
In-depth analysis of multiple inheritance issues of Python classes, and in-depth analysis of python
Body
First, you must note that Python classes are classified into classic classes and new classes.The classic class is something before python2.2,
Python crawler framework Scrapy installation and configuration, pythonscrapy
The previous 10 chapters of crawler notes record some simple Python crawler knowledge,It is used to solve simple post download problems, and the point-of-performance
Compress python crawlers to generate exe files,
1. Download and decompress pyinstaller (you can download the latest version from the official website ):Https://github.com/pyinstaller/pyinstaller/
2. Download and install pywin32 (note that my
Two important concepts in urllib2: Openers, Handlers, and urllib2openers
Before starting the following content, let's first explain the two methods in urllib2: info/geturlThe response object response (or HTTPError instance) returned by urlopen has
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