First, Module introductionModule: A module is a collection of functionsThere are three sources of modules: 1. Built-in Modules2. Third-party modules3. Custom ModulesFormat of the module: 1. py files written using Python2. C or C + + extensions that
expandtabs (): # \ t is a tab, \ n is a newline. Segmentation Test= "1234567\t89"V=test.expandtabs (20)Print (V,len (v))isdecimal (): #当前输入的是不是数字 isdigit (): #当前输入的是不是数字 isnumeric (): #判断当前输入的是否是数字 Test= "②"V1=test.isdecimal ()V2=test.isdigit
Continue and break use#continue effect: End this cycle and continue the next cycle#break function: Jump out of the entire cycleFor I in Range (Ten):If I Continueprint (i)For J in range:print ("Layer2", j)if J = = 6: Break#标志位的作用: Equivalent to set
Implement simple operations on a file#!/usr/bin/env python#-*-coding:utf-8-*-defFind (class_name): Class_list=[] Tag=False with open ('Data','R', encoding='UTF8') as F: forLineinchF:ifLine.strip () = ='class: {0} class'. Format (Class_name.strip ()):
ReadLinesJust like read without parameters, ReadLines can read the entire file in a row and return a list with the data of each row being an element # coding=utf-8 f = open ( " Test.txt ", " R " ) content = F.readlines () print (type (
Hill sort first selects the increment, groups the original list, and then sorts the same array using the direct insertion method, the last increment is 1, and the global sort is achieved.1 " "2 Hill Sort3 Space Complexity O (1)4 The Worst of Time
Interception of Python strings0 is the first,-1 is the last, as long as it's negative, it's reversed.str = ' Welcome to China ' A = Str[3]b = Str[11:]c = Str[-1]d = Str[3:11]f = Str[0:]print ("A output is:" + a) print ("B output is:" + B) p Rint ("C
1 Import Functools 2 int2 = functools.partial (int, base=2)3print('int2 ' ))456 max2 = functools.partial (max, ten)7 Print (Max2 (2,6,0,8)) The function of functools.partial is to fix certain parameters of a function (that is, to set default
Encountered a topic in leetcode operations involving the deletion of elements of an array: Remove and DelThe main idea is to delete duplicate data from an arrayThe code submitted is as follows (Python3):"Created on 5, 2018@author:m24" from math
The selection of multiple libraries for Python crawlers is repeated, and always does not know which one to choose, by trying multiple nights of choice
Reques
BeautifulSoup
The above two libraries are enough crawlers to crawl the data of
Functions can be broken down into built-in functions and custom functions. The main focus of this time is the custom function. Once the function is defined, it can be called wherever it is needed.1 Importance of the return value3 cases of Return
Installation:pip install virtualenvUse to create a virtual environment:cd project_dirvirtualenv venv When you create a virtual environment, you copy all the libraries in the current PIP environment to the newly created virtual environmentActivating
Recently in the internship, boss to decorate a small Python task, learning process found copy () and deepcopy () this is a bit too good for the base friend, make the blogger is a bit silly to distinguish ah, but in the spirit of a probe in the end,
Str.join () splicing with XXList and dictionary re-circulation when the deletion will be omittedCopy a new dictionary or a new list to delete with the new dictionary or the values in the new column tableThe. Fromkeys () returns to the new dictionary
Djangoform Basic Knowledge Summary1. What is a form? A component used to verify the legitimacy of user request data 2, the implementation steps of the Django form: A. Create a template that validates user requests from the Django Import Forms Class
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