Directly run the Code:Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-Import QueueImport threadingImport urllibImport urllib2Import OS
Def down (url, n ):Print 'item' + str (n) + 'start'Filename = urllib2.unquote (url). decode ('utf8'). split ('
The latest delay monitoring of the weather service is to check whether the weather data changes once every hour, and trigger an alarm if the weather data does not change three times. Since the data on the page is in json format, we should first
1. List derivation:
[Expression for variable in list] or [expression for variable in list if condition]
2. Examples:
Copy codeThe Code is as follows:#! /Usr/bin/python#-*-Coding: UTF-8 -*-
Li = [1, 2, 3, 4, 5, 6, 7, 8, 9]Print [x ** 2 for x in
1. algorithm :(Array [low, high])
(1) determine the intermediate position K in the period(2) Compare the searched value T with array [k. If they are equal, the location is returned if the search is successful. Otherwise, the new search area is
Copy codeThe Code is as follows:
Import MySQLdbTry:Conn = MySQLdb. connect (host = 'localhost', user = 'root', passwd = 'root', db = 'test', port = 3306)Cur = conn. cursor ()Cur.exe cute ('select * from user ')Cur. close ()Conn. close ()Counter t
Let's look at an example:Copy codeThe Code is as follows:>>> Def foo (* args, ** kwargs ):Print 'args = ', argsPrint 'kwargs = ', kwargsPrint '-----------------------'
>>> If _ name _ = '_ main __':Foo (1, 2, 3, 4)Foo (a = 1, B = 2, c = 3)Foo (1, 2,
Create: list = [5, 7, 9]Value and value change: list [1] = list [1] * 5Insert at the end of the list: list. append (4)Remove the 0th values and return the value of The 0th values: list. pop (0)Remove the 0th values but no value is returned: del
This chapter introduces the concept of data structure. A Data Structure is a collection of data elements that are organized together in some way. In python, the most basic data structure is the sequence. Each element in the sequence is assigned a
Split and join methods of stringOperating system. path. splie ()/OS. path. join () for the imported OS module seems to have different processing mechanisms, but the functions are the same.1. string. split (str = '', num = string. count (str): string
This article describes how to organize a statement into a function. It also describes the concepts of parameters and scopes, as well as the concept of recursion and its usage in the program.1. Create a functionA function can be called. It executes
There are two methods for Python file traversal: one is the more convenient OS. walk (), and the other is the use of OS. listdir () recursive traversal.
Method 1: Use OS. walk
OS. you can traverse the entire file tree from top down or bottom up, and
Some time ago, I prepared Baidu for an interview. Although I was beaten, I still put the "trophy" in those days. The algorithm has always been a weak place, we need to work harder in the future.
Below we use Python to implement several common
I. Sort the list
The recommended sorting method is the built-in sort () method, which is the fastest and stable.Copy codeThe Code is as follows:>>> A = [1, 9, 3, 7, 2, 0, 5]>>> A. sort ()>>> Print[0, 1, 2, 3, 5, 7, 9]>>> A. sort (reverse = True)>>>
Before introducing yield, it is necessary to describe iterator and constructor in Python ).
I. iterator)
In Python, A for loop can be used for any type in Python, including list and ancestor. In fact, a for loop can be used for any "iteratable
Flask depends on two external libraries: Werkzeug and Jinja2. Werkzeug is a WSGI (standard Python interface developed and deployed between web applications and multiple servers) tool set. Jinja2 is responsible for rendering templates.
I.
Specific websocket introduction visible http://zh.wikipedia.org/wiki/WebSocket
This section describes how to use Python to communicate with front-end js.
After websocket uses the HTTP protocol to complete handshake, it does not directly communicate
Premise: the isp must support web login.
Note: The logon pages of each ISP are different, but I guess the algorithms are the same, so the solution should be similar, but the keys of the form may be different.
First, analyze the logon page.
The page
Anaconda is a scientific computing environment similar to Canopy, but it is more convenient to use. The built-in package manager conda is also very powerful.
First, download and install. Anaconda provides two versions: Python2.7 and Python3.4. If
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