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
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 =
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:>>>
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
#
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: >>>
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 _
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
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
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
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
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
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:
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),
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.
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
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
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