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:>>>
After installing the installation file, run import mysqldb. the following error occurs:
File "C: \ python26 \ Lib \ Site-packages \ mysqldb \__ init _. py", line 19, in
Importerror: DLL load failed: the specified module cannot be found.
After
For example, to convert a String object s from a GBK internal code to a UTF-8, you can do the following:
S. Decode ('gbk'). encode ('utf-8 ′)
However, in actual development, I found that exceptions often occur in this method:
Unicodedecodeerror:
Note that an array of characters is passed in. the compiler removes all corresponding characters at both ends until no matching characters exist, for example:
CopyCodeThe Code is as follows: thestring = 'saaaay Yes No yaaaass'
Print thestring.
For example:
>>> Print ord ('A ')
97
>>> Print CHR (97)
A
Next we can start to design our case-insensitive Conversion
ProgramNow:
CopyCodeThe Code is as follows :#! /Usr/bin/ENV Python
# Coding = UTF-8
Def ucasechar (CH ):If ord (CH) in
1. First, the export function of VC ++ DLL is defined as the export function of Standard C:
CopyCode The Code is as follows: # ifdef lrdlltest_exports
# Define lrdlltest_api _ declspec (dllexport)
# Else
# Define lrdlltest_api _ declspec (dllimport)
1. String. maketrans set the String Conversion rule table (translation table)
CopyCode The Code is as follows: allchars = string. maketrans ('','') # All strings, that is, the strings are not replaced.
Atob = string. maketrans ('A', 'B') #
1. Set the fomat format as follows:
CopyCodeThe Code is as follows: # Take the first five characters, skip the four Chinese characters, and then take three more characters
Format = '5s 4x 3s'
2. Use struck. Unpack to obtain the substringCopy
CopyCode The Code is as follows: mulline = "" Hello !!!
Wellcome to Python's world!
There are a lot of interesting things!
Enjoy yourself. Thank you! """
Print ''. Join (mulline. splitlines ())Print '------------'Print ''. Join (mulline.
For example:
Class
Book
(
Object
):
Def
_ Setattr __
(
Self
,
Name
,
Value
):
If
Name
=
'Value'
:
Object
.
_ Setattr __
(
Self
,
Name
,
Value
-
100
)
Else
1. Server (server. py)
What the server must do is:
1. Create a socket object
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Import
SocketS
=
Socket. socket (socket. af_inet, socket.
The example can be downloaded from the attachment.
1. load XML files
There are two ways to load an XML file: loading a specified string and loading a specified file.
2. Obtain the Element Method
A) through getiterator
B) getchildren
C) Find Method
D)
CopyCode The Code is as follows: #-*-coding: UTF-8 -*-
Import threading
Import time
Def fun (name, ls_name, front_thread = none ):
'''''
Thread start Function
Use front_thread to run threads in an orderly manner
'''
Time. Clock ()
Time. Sleep (2)
#
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
#
CopyCodeThe Code is as follows: def find_file_by_pattern (pattern = '. *', base = ".", circle = true ):
''''' Search for all ''' under a given folder '''
Re_file = Re. Compile (pattern)
If base = ".":
Base = OS. getcwd ()
Final_file_list =
1. Self, CLS is not a keyword
In python, self and Cls are not keywords and can be replaced by any variable you write.
Code 1
Copy code The Code is as follows: Class mytest:
Myname = 'Peter'
Def sayhello (Hello ):
Print "Say hello to % s" % Hello.
In Python, initialize an array of 5x3 and each item is 0. The best method is:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Multilist = [[0 for col in range (5)] for row in range (3)]
We know that
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