Python's interpretive language also has a dedicated threading model, with the Python virtual machine using Gil (Global interpreter lock, the globe interpreter Lock) to mutually exclusive threads accessing shared resources, but temporarily unable to
After using Python for a while, it can be said that the basic unit of Python is the module, and we use the import statement to import it when we use the module, but we can use some of these functions when we're not importing any modules: Int (), str
This example describes how Python uses the sorted function to sort the list. Share to everyone for your reference. Specifically as follows:
Python provides the sorted function to sort the list, and it can be arranged in either a positive or reverse
We have mentioned how Oyster.com's Python Web server leverages a huge Python dicts (hash table) to cache large amounts of static resources. We recently in the image class, with just one line of __slots__ code, so that each 6G memory footprint of the
Python supports multithreading and is a native thread. Mainly through the thread and threading these two modules to achieve. Thread is the lower level of the module, threading is the thread made some packaging, can be more convenient to use. One
Creating Threads
Format is as follows
Copy Code code as follows:
Threading. Thread (Group=none, Target=none, Name=none, args= (), kwargs={})
This constructor must be invoked with a keyword pass parameter
-Group Thread
This article is an example of how Python prints the Scrapy spider crawl tree structure. Share to everyone for your reference. Specifically as follows:
The following code can be understood at a Glance scrapy crawl page structure, the call is very
If you use input and raw_input to read a file directly on the command line, and you want to take the file directly into the command line to handle it,
The input method can be handled directly, and if you want to use the Raw_input method, the
Join is used to concatenate strings, split is the opposite, split string.Do not have to explain, read the code, its meaning from the present.
Copy Code code as follows:
>>>li = [' i ', ' name ', ' is ', ' Bob ']
>>> '. Join (LI)
'
1. If the module is imported, the __name__ value is the module name2. If the module is executed directly, the value of __name__ is ' __main__ '
py1.py
Copy Code code as follows:
#! /usr/bin/env python
def test ():
print ' __name__
A reference is an address that holds a value that is an object. In the Python language, the values saved by a variable are referenced except for the basic type, so it is necessary to be careful about their use. Here's an example:
Problem
Before the bottle did a lot of introduction, but also wrote some articles to explain the shortcomings of bottle, recently found that in fact, some places said before the unfair, so take advantage of this opportunity to correct.
Bottle is the syntax
Basic mapping
Mappings are used to generate corresponding return content based on different URL requests. Bottle uses the route () modifier to implement the mapping.
From bottle import route, Run@route ('/hello ') def-hello (): return
The with in Python can significantly improve code friendliness, such as:
Copy Code code as follows:
With open (' a.txt ') as F:
Print F.readlines ()
For our own classes can also use with, as long as the class to add two
Format
Getopt (args, options[, long_options])
1.args represents the parameters to resolve.2.options indicates the character to be recognized by the script. The characters are delimited by ":" and Must End with ":", such as "A:B:C:".3.long_options
Open File
The open function returns a file object, the basic syntax:
File_object = open (file_name, access_mode= ' R ' [, Buffering=-1])File_name is a string containing the name of the file you want to open, which can be a relative or absolute
This article is an example of how Python obtains native extranet IP. Share to everyone for your reference. Specifically as follows:
Python Gets the native extranet IP from the Web site that displays the IP address, and this Python code crawls the
Django's querysets are cool!
In this article I'll explain what querysets is, how it works (if you're already familiar with it, you can skip to the second part), I think you should always return to the Querysets object if you can, so let me talk
Micro-letter This thing estimated that otaku few unfamiliar, micro-letter after so many years of development finally to the open platform to make a friendly step. Egg pain thought the micro-letter will be a detailed API and other interfaces, excited
The example in this article describes how Python implements a function in each stand-alone process. Share to everyone for your reference. The specific analysis is as follows:
This simple function can be used to run another function in a separate
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