Little practice of concurrent crawlers.Paste directly locally, run as a. py file, and run with a parameter that you want to crawl. The default is this blog.The output is a directory named after the user name, which is the content in the blog.A
Today online server All upgrade Python environment for python-2.7.6 Environment, I use the method is Ansible+shell, code as follows, friend, Python-2.7.6.tgz, setuptools-14.3.1.tar.gz, Pip-9.0.1.tar.gz, these three bags I was in advance under
1 #1. The most basic way to read files:2 3 #file:readline-example-1.py4 5File = Open ("Sample.txt")6 7 while1:8line =File.readline ()9 if notLine :Ten Break One Pass #Do something A #It is obviously slower to read data from
1, Python 3 installation.2, Python development tool Pycharm installation.3. Print ("Hello world!") #打印hello world! Note: Python 3 needs to be added (). 4, #!/usr/bin/python3 or #!/usr/bin/env python3 tell what language to explain, each file must
Python module--time moduleFirst, the Python Time introduction:There are two ways to represent time in Python: 1, timestamp notation, that is, an integer or float type is a time interval in seconds. The base value for this time is calculated from 0
As a veteran in the IT circle for many years (although the technology now has a lot of upside-down changes), but not programming, has always been a pain in my it circle, from C, C + +, until PHP, has been a lot of primer books, have been very eager
Use Python for host disk usage, but use Influxdb+grafana to show each other#!/usr/bin/env python# _*_ Coding:utf-8 _*_Import OSImport reImport JSONImport timeFrom influxdb import influxdbclientDef getinfluxdb ():Client=influxdbclient (host= ' 192.168
python upgrade steps under Linux Python2->python3
In most cases, the system's automatic Python version is 2.x
or yum directly installed 2.x.
However, in most cases it is recommended to use 3.x
So how to upgrade it?
The following
1. Note the difference between the list and the set setList representation: List_1 = [1,3,4]; Set representation: set_1= Set ()list_1 = [1,2,3,4,23,4,2]Print(List_1,type (list_1)) list_1=Set (list_1)Print(List_1,type (list_1)) List_2= Set ([2,4,6,8,1
Copy---Explore1. Shallow copy is equivalent to pointing the variable pointer to the object equivalent to giving the object a new nickname.a=[[1,2],3,4]a=[[1,2],3,4]b=a.copy ()#print (a)#print (b)#>>>>[[1, 2], 3, 4]#>>>>[[1, 2], 3, 4]#b[2]=1#print (a)
1. Print the progress barImport Sys,time for in range: sys.stdout.write ("#" )# print output without waiting for the buffer to be full Time.sleep (0.1)2. "R+", "w+", "A +", "RB" reading and writing mode, read-write mode, append read/write
Method One: Method of slicingA = "Hello"b = Len (a)i = 1c = ""While ID = a[b-i]c + = dI+=1Print CMethod Two: Convert the string to a list reverse () method reverses the list (no return value) to stitch the list again into a stringA = "Hello"b = List
Create a function
A record function, which writes a string at the beginning of a function, is stored as part of the function, which is called a document string, such as
def Square (x): ' Caculates the square of the number x. 'Return x*x
>>>
PRint related
Print prints multiple expressions, as long as they are separated by commas, and a space is inserted between each parameter in the result, using + to avoid spaces, such as
>>> print ' Age: ', 42Age:42>>> print ' hello ' + ', ' + '
1, if you want a list of index and content, you can quickly achieve through the enumerate
drinks = [' coffee ', ' tea ', ' milk ', ' water ']for index, drink in enumerate (drinks): PRint (' Item {} is {} '. Format (index, Drin k)) #Result # item 0
After the successful installation of Python, that is, to configure the development environment, where eclipse, install the Pydev plug-in in eclipse, there are many ways, here are the most commonly used two.
1) using the Eclipse installation plugin,
1 #Author:ersa2 " "3 key-value Key-value Pairs4 dictionaries are unordered, do not need subscript, there is a key5 dictionary search, modify, add, judge, Delete6 " "7 8info = {9 'stu1101':"Tenglan Wu",Ten 'stu1102':"Longze Luola", one
Python development [front-end]: Ajax, python front-end ajaxAjax is called"SynchronousJAvascript AndXML"(Asynchronous JavaScript and XML) is a web page development technology used to create interactive web applications. AJAX = Asynchronous JavaScript
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