Python del () function usage

ExampleProgramAs follows: >>> A = [-1, 3, 'A', 85] # define a list>>>[-1, 3, 'A', 85]>>> Del a [0] # Delete 0th Elements>>>[3, 'A', 85]>>> Del a [] # Delete elements starting from 2nd elements and ending with 4th elements. Include header not

Usage of Python string split

For example, the storage format is: Format: Name, age | Name of another user, age Name: Haha, age: 20 | Name: Python, age: 30 | Name: FEF, age: 55 Then we can use the split method of the string object to cut the string object into a list. A =

Python Regular Expression usage experience

1. Match () starts matching from the starting position2. Search () matches any position. If multiple matches exist, only the first matches are returned.3. finditer () returns all matches4. Every matching is the best matching possible. For example:>>>

Python data encryption code

1. hashlibImport hashlib # Create a hash object MD = hashlib. MD5 () # MD = hashlib. sha1 () # MD = hashlib. shavel () # MD = hashlib. sha25 () # MD = hashlib. sha384 () # MD = hashlib. sha512 () 1.1 hashlib. Update (ARG) 1.2 hashlib.

Python allows you to copy or cut all files in a file list.

CopyCode The Code is as follows: # Coding: UTF-8 Import OS Import sys Def cut_and_paste_file (source, destination ): ''' Source: file path (Chinese) Destination: directory path ''' Def format_path (PATH ): If not OS. Path. isabs (PATH ): Path = OS.

Python file renaming tool code

CopyCode The Code is as follows: # filename: BRN. py # Description: Batch replace certain words in file names # Use to bat rename the file in a Dir (modify the Suffix from A to B) for Windows Vista OS Import sys Import OS Import fnmatch Import re #

Itertools for python arrangement and combination

Python 2.6 introduces the itertools module to simplify the implementation of arrangement and combination: Copy codeThe Code is as follows: import itertools Ordered sorting: e.g., select two of the four numbers:Copy codeThe Code is as follows: >>>

Example code for sending emails in python (html, images, and attachments are supported)

Code 1: Copy codeThe Code is as follows :#! /Usr/bin/python #-*-Coding: UTF-8 -*- Import emailImport mimetypesFrom email. MIMEMultipart import MIMEMultipartFrom email. MIMEText import MIMETextFrom email. MIMEImage import MIMEImageImport smtplib Def

Share the default value of python functions with reference learning notes

Copy codeThe Code is as follows: import random, string Class C (object): pass Def dangerFunction (msg, l = [], B = {}, c = C ()): Print msg, '-' * 10 Print l, B, c. _ dict __ L. append (1) B [random. choice (string. ascii_lowercase)] ='' C. _ dict _

In python, find the duplicate data of a column in excel and print it after elimination.

1. For simple read/write operations on excel in python, xlrd (especially read Operations) is recommended) 2. Go to the http://pypi.python.org/pypi/xlrd to download the xlrd library; 3. The project code is as follows: Copy codeThe Code is as

The signing program of Kingsoft disk implemented by Python

Copy codeThe Code is as follows: __author _ = 'clownfish' # Coding: UTF-8 Import urllib2, urllib, cookielib, json Username = "quick disk username"Password = "quick disk password" Class sign (object ):Username =''Password =''# Logon display

Analysis and Implementation of simple server Construction Using python

Requirement Analysis: The number of users of the province's oil and gas has already exceeded 6000, and the original static reports have become bloated, It takes up to half a day to open each time, and even the browser crashes directly. Build a

Parse the blocking mode of AutoResetEvent in python

People who have worked on C # multithreading understand AutoResetEvent and ManualResetEvent, including the WaitOne () method, Set () and Reset () method () many methods are used in thread synchronization. AutoResetEvent: When a thread executes the

Python weather forecast collector implementation code (Web Crawler)

Crawlers take two steps: obtaining webpage text and filtering data.    1. Obtain html text.Python is very convenient in getting html, and a few lines of code can implement the functions we need. Copy codeThe Code is as follows: def getHtml (url

Python code check tool pylint makes your python more standard

1. What is pylint? Pylint is a Python code analysis tool that analyzes errors in Python code and finds errors that do not conform to the Code style standards. (Pylint uses the Default Code style of PEP 8. For details, see references) code with

Python image verification code sharing

Copy codeThe Code is as follows: # coding: UTF-8 Import Image, ImageDraw, ImageFont, OS, string, random, ImageFilter Def initChars (): """ Allowed Character Set combination. The initial set is numbers, uppercase and lowercase letters. Usage:

Python algorithm sorting for fast sorting

QUICKSORT (A, p, r) is A subroutine for fast sorting. It calls the division program to divide the array, and then recursively calls QUICKSORT (A, p, r ), to complete the quick sorting process. The worst time complexity of quick sorting is O (n2),

Code for batch renaming objects using python

The following is the final code (implemented in windows) Copy codeThe Code is as follows: #-*-coding: cp936 -*- Import OS Path = 'd: \ image \\' For file in OS. listdir (path ): If OS. path. isfile (OS. path. join (path, file) = True: If file.

The Python module learns the re regular expression.

Re. match Re. match tries to match a pattern from the beginning of the string. For example, the following example matches the first word. Copy codeThe Code is as follows: import re Text = "JGood is a handsome boy, he is cool, clever, and so on

Python Array Processing code

When I was a beginner in python, I had a few questions: There is a list A = [1, 2, 3, 4, 5, 6] Set a 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 Print Output, 2. Sort a list in reverse order to [6, 5, 4, 3, 2, 1] 3. Pick out * 2 from the even number in a and the

Total Pages: 4013 1 .... 3019 3020 3021 3022 3023 .... 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.