First, the main content:Interface class: ( Only in the work, writing a specification.)Abstract class:Usefulness: At work, if you prescribe several classes, you must have the same method, if you are abstract class.Packaging:1, put some properties or
Based on Python2.71 Basic Crawl PagesGet method
importurllib2url = "http://www.baidu.com"response = urllib2.urlopen(url)printresponse.read()
Post method
Python file processing open file F = open ("path", "mode")
R modeOpen in read mode, navigate to the beginning of the file, default mode. File does not exist direct error, file can only read, cannot write.
r+ modeOpen in a read-write
Python dictionary# Data Type partitioning: mutable data type, immutable data type # immutable data type: ganso bool str int HASH # mutable data type: List Dict (dictionary) set (set) non-hash # Dict key (must be hash) value (Arbitrary data class #
Format ()Positional parameter {}>>> "{0} love {1}.com". Format ("I", "cat")' I Love cat.com 'Keyword parameters>>> ' {I} love {cat}.com '. Format (i= "You", cat= "Me")' You love me.com 'Combining positional and keyword parameters, the positional
1, current operating system environment2, install the module used by Python, install using the PIP commandYum-y Install GCC#安装pycryptowget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gzTAR-XF pycrypto-2.6.tar.gzCD
1, the Python version I used2, the following to write the specific implementation processImport threadingImport timeImport Queue#首先生成一个队列Q =queue.queue ()#生产者def producer (name):L=threading. Rlock ()For I in range (40):L.acquire ()Q.put (i)L.release
System environment: WIN10 64-bit system installationPython basic Environment configuration does not do too much introductionWindows environment installation scrapy need to rely on Pywin32, download the corresponding Python version of the exe file to
The cycle is that the computer repeatedly help us do one thing, people hate to do the repetition of dull things, like the grind, people feel boring, and then have a donkey, a circle of cycle, people a lap of a circle of push not exhausted, so the
#-*-Coding:utf-8-*-"""Created on Sat June 30 14:49:22 2018@author: Zhen"""Import NumPy as NPA = Np.array ([[1,2,3],[11,22,33]])b = Np.array ([[4,5,6],[44,55,66]])# arrays are concatenated into matricesc = Np.c_[a,b]r = np.r_[a,b]Print ('-------------
ImportOS#the file is in the location: d:\ level 1th \ 2nd level \ 3rd level \ 4th layer \ 5th Layer \test11.pypath1= Os.path.dirname (__file__)Print(path1)#gets the absolute path of the currently running scriptpath2= Os.path.dirname (Os.path.dirname
1.window operating system with the encoding format is GBK,PYTHON3 encoding format is utf_8;2. File Stream ProcessingGet the file handle through open (), manipulate the operating system through the handle to read the contents from the document, and
1. String TypeA string in Python can be implemented with a pair of ", a pair of", or a pair of "" "" "" (1), with the note that the end-to-end cannot be consistent, such as ' or ' will throw a syntax exception (2). For three quotation marks, a
The import statement in Python can be imported into the module file, but the import statement executes the code in the module file only the first time it is imported, and then the imported module file is stored in memory, and when it is imported
Let's look at a code:Yesterday2 is the file I created last post, in order to make it easier for everyone to see I copied the original code to the following:Coding=utf-8F=open ("Yesterday2", "R", encoding= "Utf-8")F_new=open ("Yesterday2.bak", "W",
案例1:程序输入输出案例2:判断合法用户安全3:编写判断成绩的程序1 Case 1: program input and output1.1 QuestionsWrite the login.py script to achieve the following goals:提示用户输入用户名将用户名保存在变量中在屏幕上显示欢迎用户的信息1.2 SolutionsIn many cases, programs are required to interact with the user when
#-*-Coding:utf-8-*-"""Created on Sat June 30 10:09:47 2018Test group GroupBy@author: Zhen"""From pandas import DataFrame"""data = [[1,2,2,1][2,2,2,2][1,3,3,2][2,2,2,4]]"""# Create test data, convert dictionary into data frameDF = DataFrame ({' A ': [
Tag: number form sort length ESS%s Delete animal LANPython's data structure is: list, tuple, dictionaryList:Function: Data structure for processing ordered itemsList=["A", ' B ', ' V ', ' d ')# Print LengthPrint (Len (list))# Loop PrintFor I in list:
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