://blog.csdn.net /lanphaday/archive/2007/10/28/1852726.aspx) and "Computational Image similarity" (http://blog.csdn.net/lanphaday/archive/2008/04/24/ 2325027.aspx).
MySQLdbThis is Python's support for open source database Mysql, the official website in Http://sourceforge.net/projects/mysql-python. Support for the full range of Mysql 3.23-5.1 version, the Python version of the requirements are 2.3-2.5. MYSQL
ObjectiveThe so-called Web crawl, is the URL address specified in the network resources from the network stream read out, save to Local. There are many libraries in python that can be used to crawl Web pages, so let's learn urllib first.Note: This blog development environment is Python3UrlopenLet's start with a piece of code:# urllib_urlopen.py# 导入urllib.requestimport urllib.request# 向指定的url发送请求,并返回服务器响应的类文
Dir function to view the properties of an objectThe use of the method is simple, for example, the OS type, in the Python command Window input dir (' OS ') to view the properties of the OS moduleOpen cmd Command WindowEnter Python (note: The computer needs a Python environment and the Python environment variable is conf
/537.36"= urllib2. Request (URL, headers == urllib2.urlopen (request)print response.read ()The following error message appears when you run the program:Urllib2. Urlerror: Therefore, if you encounter such a site in the future, we need to handle the SSL certificate separately, let the program ignore the SSL certificate validation error, can be accessed normally.ImportUrllibImportUrllib2#Import Python SSL processing moduleImportSSL#Ignore unverified SSL
(width)] ' for ' in range (1, width-1): rows[0][x] = HO Rizontal Rows[height-1][x] = Horizontal for y in range (1, height-1): rows[y][0] = VERTICAL row S[Y][WIDTH-1] = VERTICAL for y, X in ((0, 0), (0, Width-1), (height-1, 0), (height-1, width-1)): ROWS[Y][X] = CORNER return rowsclass rectangle:def __init__ (self, x, y, width, height, fill, stroke): s elf.x = x self.y = y Self.rows = _create_rectangle (width, height, BLANK if fill = = "White" El Se "%") class Text:def __init__ (self, x,
Installing third-party libraries with Easy_install and Pip is convenientThey are actually downloaded from the official Python source Pypi.python.org/pypi to the local, then unpacked and installed.But for some reason, access to the official PyPI is unstable, slow or even inaccessible.As with Ubuntu's apt and CentOS's yum, there are various image sources like PyPI.The source of the highly recommended watercre
Fuzz.ratio ("Hit me with your best shot", "Hit me with your pet shark")
# 85
8) ProgressBar
As its name, a scroll bar function library
Copy Code code as follows:
From ProgressBar import ProgressBar
Import time
Pbar = ProgressBar (maxval=10)
For I in range (1, 11):
Pbar.update (i)
Time.sleep (1)
Pbar.finish ()
# 60% |######################################################## |
9) Colorama
A color library that can add rich colors to the text
Graviti
‘‘‘
4.wget, more useful library, can be used to download pictures
Import wget
Url = "https://timgsa.baidu.com/timg?imagequality=80size=b9999_10000sec=1532975831713di=6add9fa41ac1a7ddbddcaa919d49c497imgtype=0src=http%3A%2F%2Fimage.uczzd.cn%2F6715434799472055716.jpeg%3Fid%3D0"
# Parameter one: url, downloaded address, parameter two: out, output file name or path
Wget.download(url=url, out=r"C:\Users\Administrator\Desktop\aaa\matsuri.jpg"
Of course, enter
1.bisect: Use the dichotomy to find the appropriate insertion position in a sorted sequence.>>>import bisect>>>l = [10,19,88,90]>>>bisect.bisect (l, a) >>>2 # The position suitable for insertion is 2bisect.bisect_left (l, #如果已经在列表中存在) and returns to the left position Bisect.insort_left (l,22) #插入2.HEAPQ: Fully balanced binary tree, all nodes are smaller than their child nodes.From HEAPQ import *from random Import *l = sample (Xrange (+), ten) heap = []print lfor i in L:heappush (heap, i) Pri
1, Os.pathOs.path.split (): OS split path, returns a tuple, the first is a path, the second is a file name;Os.path.basename (): Get file name only;Os.path.dirname (): Get path only;Os.path.splitext (): Separates the path, file name, extension, and returns a tuple;Os.path.commonprefix: In a set of paths, look for a common prefix;Os.path.jion (): combine some scattered strings to generate a secure path;Os.path.expanduser (): Look for the eternal home directory;Os.path.expandvars (): The value of t
execute the SQL command when executing the query, pay attention to the security of the SQL statement,
C=conn.cursor ()# never do this--insecure!Symbol = ' Rhat 'C.execute ("SELECT * from stocks WHERE symbol = '%s '"% symbol)?# do this instead, note that there is only one element in a tuple followed by a comma#sql语句中的替换符为?t = (' Rhat ',)C.execute (' SELECT * from stocks WHERE symbol=? ', T)Print (C.fetchone ())?# Larger example that inserts many records at a
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.