Getting Started with the python-module

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

Common methods in the Python list

#Author: Yue#列表li=[1,2,3,4,5]# 1. Append the value# Li.append (5)# Print (LI)# [1, 2, 3, 4, 5, 5]# li.append (' Yue ')# Print (LI)# [1, 2, 3, 4, 5, ' Yue ']# 2. Clear the list# li.clear ()# Print (LI)# []# 3 Copy Shallow copy# v = li.copy ()#

Python Requests Request encapsulation

#encoding =utf-8Import requestsImport JSONClass HttpClient (object):def __init__ (self):Passdef __post (Self,url,data=none,json=none,**kargs):Response=requests.post (Url=url,data=data,json=json)return responsedef __get (Self,url,params=none,**kargs):

Python Homework 001

1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 4 ImportGetpass5Name ="Xilong"6Password ="--------"7WorkID = 100081798 9File = Open ("Xilong.txt","r+", encoding="Utf-8")TenCount =0 One whileCount : A_name = input ("Name:") -_mima = Getpass.getpass

Python Study the third day

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

Python learning: Continue and break usage

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

Python gets Excel data

#!/usr/bin/python# --*-- coding: utf-8 --*--import xlrdexcel_file =  "/data/ Script/cmdb_excel_2018_08_04_16_03.xlsx "csv_file = "/data/script/jms.xlsx "################ #get   old jms ip_list ################### #workbook  = xlrd.open_workbook

Python Action on files

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 ()):

Python file Operation two

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 (

Insert Sort _ Hill Sort (python)

pow

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 strings

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

Python Partial functions Partial function

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

The difference between the Python remove and Del

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

A new solution to Python crawler

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

Python Learning path Basic Article--09python Foundation, Primary knowledge function

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

Python PIP Virtual Environment uses

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

Python Send mail

import smtplibfrom email.mime.text import mimetextfrom email.mime.multipart  Import mimemultipartfrom email.mime.image import mimeimagedef get_content (Text,type):     ret = mimetext (Text,type)     return retdef get _img (Imgfile,imgid):

Python-copy () differs from deepcopy ()

 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,

Python Learning DAY07

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

A summary of Python learning---djangoform

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

Total Pages: 4013 1 .... 3443 3444 3445 3446 3447 .... 4013 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.