- 浏览: 2952329 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (2529)
- finance (1459)
- technology (218)
- life (343)
- play (150)
- technology-component (0)
- idea (6)
- house (74)
- health (75)
- work (32)
- joke (23)
- blog (1)
- amazing (13)
- important (22)
- study (13)
- Alternative (0)
- funny (8)
- stock_technology (12)
- business (16)
- car (21)
- decorate (4)
- basketball (2)
- English (16)
- banker (1)
- TheBest (1)
- sample (2)
- love (13)
- management (4)
最新评论
-
zhongmin2012:
BSM确实需要实践,标准ITIL服务流程支持,要做好,需要花费 ...
BSM实施之前做什么 -
shw340518:
提示楼主,有时间逻辑bug:是你妈二十那年写的 那会儿连你爹都 ...
80后辣妈给未来儿子的信~我的儿,你也给我记住了~~~ -
guoapeng:
有相关的文档吗?
it项目管理表格(包含146个DOC文档模板) -
solomon:
看到的都是 这种 CTRL+C 和 CTRL+V 的文章, ...
Designing a website with InfoGlue components -
wendal:
恩, 不错. 有参考价值
Designing a website with InfoGlue components
Python 2.5 Quick Reference 收藏
<script type="text/javascript"> document.body.oncopy = function() { if (window.clipboardData) { setTimeout(function() { var text = clipboardData.getData("text"); if (text && text.length > 300) { text = text + "\r\n\n本文来自CSDN博客,转载请标明出处:" + location.href; clipboardData.setData("text", text); } }, 100); } } </script><script type="text/javascript"> function StorePage() { d = document; t = d.selection ? (d.selection.type != 'None' ? d.selection.createRange().text : '') : (d.getSelection ? d.getSelection() : ''); void (keyit = window.open('http://www.365key.com/storeit.aspx?t=' + escape(d.title) + '&u=' + escape(d.location.href) + '&c=' + escape(t), 'keyit', 'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes')); keyit.focus(); }</script>
Style chooser: Modern
, Modern Black&White
, Classic
, High contrast
or Printing
[Hint
: Use styles Modern
Black & White or Printing to print. If you get problems, try
printing the
PDF versions
instead]
Contents
- Front matter
- Invocation Options
- Environment variables
- Lexical entities : keywords , identifiers , string literals , boolean constants , numbers , sequences , dictionaries , operators
- Basic types and their operations: None , bool , Numeric types , sequence types , list , dictionary , string , file , set , date/time
- Advanced types
- Statements : assignment , conditional expressions , control flow , exceptions , name space , function def , class def
- Iterators ; Generators ; Descriptors ; Decorators
- Built-in Functions
- Built-in Exceptions
- Standard methods & operators redefinition in user-created Classes
- Special informative state attributes for some types
- Important modules : sys , os , posix , posixpath , shutil , time , string , re , math , getopt
- List of modules in the base distribution
- Workspace exploration and idiom hints
- Python mode for Emacs
Front matter
Version 2.5 (What's
new?
)
Check updates at http://rgruet.free.fr/#QuickRef
.
Please report
errors, inaccuracies and suggestions to Richard Gruet
(pqr at rgruet.net).
Color coding:
Features added in 2.4 since 2.3
Features added in 2.3 since 2.2
Features added in 2.2 since 2.1
Originally based on:
- Python Bestiary, author: Ken Manheimer
- Python manuals , authors: Guido van Rossum and Fred Drake
- python-mode.el, author: Tim Peters
- and the readers of comp.lang.python
Useful links :
- Python's nest : http://www.python.org
- Official documentation : http://www.python.org/doc/ [Module index ; Language Reference ]
- Other doc & free books : FAQs , Faqts , Dive into Python , Python Cookbook , Thinking in Python , Text processing in Python
- Getting started : Official site , 7mn to Hello World (windows)
- Topics : Databases , Web programming , XML , Web Services , Parsers , Scientific Computing , GUI programming , Distributing
- Where to find packages : Easy Install , Python Package Index (PyPI) , Vaults of Parnassus , SourceForge (search "python") , Python Eggs , O'Reilly Python DevCenter , Starship Python
- Wiki : moinmoin
- Newsgroups : comp.lang.python and comp.lang.python.announce
- Misc pages : Daily Python URL , Kevin Altis' WebLog , PEAK
- Python Development : http://www.python.org/dev/
- Jython - Java implementation of Python: http://www.jython.org/
- IronPython - Python on .Net: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
- ActivePython : http://www.ActiveState.com/ASPN/Python/
- Help desk : help@python.org
- 2 excellent Python reference books : Python Essential Reference by David Beazley & Guido Van Rossum (Other New Riders) and Python in a nutshell by Alex martelli (O'Reilly).
- Python 2.4 Reference Card (cheatsheet) by Laurent Pointal, designed for printing (15 pages).
- Online Python 2.2 Quick Reference by the New Mexico Tech Computer Center.
Tip : From within the Python interpreter, type<!-- INVOCATION OPTIONS -->help
,help(object )
orhelp("name ")
to get help.
Invocation Options
python [w ] [-dEhim OQStuUvVWxX?] [-c command | scriptFile | - ] [args ]
(pythonw does not open a terminal/console; python does)
-d | Output parser debugging information (also PYTHONDEBUG=x) |
-E | Ignore environment variables (such as PYTHONPATH) |
-h | Print a help message and exit (formerly -?) |
-i | Inspect interactively after running script (also PYTHONINSPECT=x) and force prompts, even if stdin appears not to be a terminal. |
-m module | Search for module
on sys.path
and runs the
module as a script. (Implementation improved in
2.5: module runpy
)
|
-O | Optimize generated bytecode (also PYTHONOPTIMIZE=x). Asserts are suppressed. |
-OO | Remove doc-strings in addition to the -O optimizations. |
-Q arg | Division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew |
-S | Don't perform import site
on initialization. |
-t | Issue warnings about inconsistent tab usage (-tt: issue errors). |
-u | Unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x). |
-U | Force Python to interpret all string literals as Unicode literals. |
-v | Verbose (trace import statements) (also PYTHONVERBOSE=x). |
-V | Print the Python version number and exit. |
-W arg | Warning control (arg is action:message:category:module:lineno) |
-x | Skip first line of source, allowing use of non-unix Forms of #!cmd
|
-X | Disable class based built-in exceptions (for backward compatibility management of exceptions) |
-c command | Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command). |
scriptFile | The name of a python file (.py) to execute. Read from stdin. |
- | Program read from stdin (default; interactive mode if a tty). |
args | Passed to script or command (in sys.argv[1:]
) |
If no scriptFile or command, Python enters interactive mode. |
- Available IDEs in std distrib: IDLE (tkinter based, portable), Pythonwin (on Windows). Other free IDEs: IPython (enhanced interactive Python shell), Eric , SPE , BOA constructor , PyDev (Eclipse plugin).
- Typical python module header
:
#!/usr/bin/env python
# -*- coding: latin1 -*-# -*- coding: encoding -*-
- It's now a syntax error if a module contains string literals with 8-bit characters but doesn't have an encoding declaration (was a warning before).
- Since 2.5,
from __future__ import feature
statements must be declared at beginning of source file. -
Site customization
: File
sitecustomize.py
is automatically loaded by Python if it exists in the Python path (ideally located in${PYTHONHOME}/lib/site-packages/
). -
Tip:
when launching a Python script on Windows,
<pythonHome>\python myScript.py args ...
can be reduced to :myScript.py args ...
if <pythonHome> is in the PATH envt variable, and further reduced to :myScript args ...
provided that.py;.pyw;.pyc;.pyo
is added to thePATHEXT
envt variable.
Environment variables
PYTHONHOME | Alternate prefix directory (or prefix ;exec_prefix ). The default module search path uses prefix /lib |
PYTHONPATH | Augments the default search path for module files. The format is the
same as the shell's $PATH
: one or more directory pathnames
separated by ':' or ';' without spaces around (semi-) colons !On Windows Python first searches for Registry key HKEY_LOCAL_MACHINE\Software\Python\PythonCore\x.y
\PythonPath
(default value). You can create a key named after your application with
a default string value giving the root directory path of your appl.Alternatively, you can create a text file with a .pth
extension,
containing the path(s), one per line, and put the file somewhere in the
Python search path (ideally in the site-packages/
directory). It's better to create a .pth for each application, to make
easy to uninstall them. |
PYTHONSTARTUP | If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode (no default). |
PYTHONDEBUG | If non-empty, same as -d option |
PYTHONINSPECT | If non-empty, same as -i option |
PYTHONOPTIMIZE | If non-empty, same as -O option |
PYTHONUNBUFFERED | If non-empty, same as -u option |
PYTHONVERBOSE | If non-empty, same as -v option |
PYTHONCASEOK | If non-empty, ignore case in file/module names (imports) |
Notable lexical entities
Keywords
and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass with def finally in print yield
- (List of keywords available in std module: keyword )
- Illegitimate Tokens (only valid in strings):
$ ?
(plus@
before 2.4) - A statement must all be on a single line. To break a statement over
multiple lines, use "\
", as with the C preprocessor.
Exception : can always break when inside any (), [], or {} pair, or in triple-quoted strings. - More than one statement can appear on a line if they are separated with semicolons ("; ").
- Comments start with "
#
" and continue to end of line.
Identifiers
(letter | "_") (letter | digit | "_")*
- Python identifiers keywords, attributes, etc. are case-sensitive .
- Special forms: _ ident (not imported by 'from module import *'); __ ident __ (system defined name); __ident (class-private name mangling).
String literals
Two flavors: str
(standard 8 bits locale-dependent
strings, like ascii, iso 8859-1, utf-8, ...) and unicode
(16 or 32 bits/char in utf-16 mode or 32 bits/char in utf-32 mode); one
common ancestor basestring
.
" a string enclosed by double quotes" |
' another string delimited by single quotes and with a " inside' |
''' a string containing embedded newlines and quote (') marks, can be delimited with triple quotes.''' |
""" may also use 3- double quotes as delimiters """ |
u' a unicode string' |
U" Another unicode string" |
r' a raw string where \ are kept (literalized): handy for regular expressions and windows paths!' |
R" another raw string" -- raw strings cannot end with a \ |
ur' a unicode raw string' |
UR" another raw unicode " |
- Use \ at end of line to continue a string on next line.
- Adjacent strings are concatened, e.g.
'Monty ' 'Python'
is the same as'Monty Python'
. -
u'hello' + ' world'
-->u'hello world'
(coerced to unicode)
\newline | Ignored (escape newline) |
\\ | Backslash (\) |
\e | Escape (ESC) |
\v | Vertical Tab (VT) |
\' | Single quote (') |
\f | Formfeed (FF) |
\ ooo | char with octal value ooo |
\" | Double quote (") |
\n | Linefeed (LF) |
\a | Bell (BEL) |
\r | Carriage Return (CR) |
\x hh | char with hex value hh |
\b | Backspace (BS) |
\t | Horizontal Tab (TAB) |
\u xxxx | Character with 16-bit hex value xxxx (unicode only) |
\U xxxxxxxx | Character with 32-bit hex value xxxxxxxx (unicode only) |
\N{ name } | Character named in the Unicode database (unicode only), e.g. u'\N{Greek
Small Letter Pi}'
<=> u'\u03c0'.
(Conversely, in module unicodedata, unicodedata.name(u'\u03c0') == 'GREEK
SMALL LETTER PI'
) |
\AnyOtherChar | left as-is, including the backslash, e.g. str('\z') == '\\z'
|
- NUL byte (
\000
) is not an end-of-string marker; NULs may be embedded in strings. - Strings (and tuples) are immutable : they cannot be modified.
Boolean constants (since 2.2.1)
<!-- NUMBERS -->
- True
- False
In 2.2.1, True and False are integers 1 and 0. Since 2.3, they are of new typebool
.
Numbers
<!-- SEQUENCES -->
- Decimal integer : 1234, 1234567890546378940L (or l)
- Octal integer: 0 177, 0 177777777777777777L (begin with a 0 )
- Hex integer: 0x FF, 0X FFFFffffFFFFFFFFFFL (begin with 0x or 0X )
- Long integer (unlimited precision): 1234567890123456L (ends with L or l ) or long( 1234)
- Float (double precision): 3. 14e-10 , .001, 10., 1E3
- Complex : 1J , 2+ 3J , 4+ 5j (ends with J or j, + separates (float) real and imaginary parts)
Integers and long integers are unified starting from release 2.2 (the L suffix is no longer required)
Sequences
- Strings (types
str
andunicode
) of length 0, 1, 2 (see above )
'', '1', "12", 'hello\n'- Tuples (type
tuple
) of length 0, 1, 2, etc:
() (1, ) (1,2) # parentheses are optional if len > 0- Lists (type
list
) of length 0, 1, 2, etc:
[] [1] [1,2]
- Indexing is 0 -based. Negative indices (usually) mean count backwards from end of sequence.
- Sequence slicing [
starting-at-index
:
but-less-than-index
[ : step]
]
.
Start defaults to 0, end to len(sequence), step
to 1
.
a = (0,1,2,3,4,5,6,7) a[3] == 3 a[-1] == 7 a[2:4] == (2, 3) a[1:] == (1, 2, 3, 4, 5, 6, 7) a[:3] == (0, 1, 2) a[:] == (0,1,2,3,4,5,6,7) # makes a copy of the sequence. a[::2] == (0, 2, 4, 6) # Only even numbers. a[::-1] = (7, 6, 5, 4, 3 , 2, 1, 0) # Reverse order.
Dictionaries (Mappings)
Dictionaries
(type dict
) of length 0, 1, 2, etc: {}
{1
: 'first'} {1 : 'first', 'two': 2, key
:value
}
Keys must be of a hashable type; Values can be any type.
<!-- OPERATORS -->Operators and their evaluation order
, [ ...] { ...} ` ...` | Tuple, list & dict. creation; string conv. | |
s[ i] s[ i: j] s. attr f( ...) | indexing & slicing; attributes, fct calls | |
+ x, - x, ~ x | Unary operators | |
x** y | Power | |
x* y x/ y x% y | mult, division, modulo | |
x+ y x- y | addition, substraction | |
x<<y x>>y | Bit shifting | |
x& y | Bitwise and | |
x^ y | Bitwise exclusive or | |
x| y | Bitwise or | |
x<
y x<=
y x>
y
x>=
y x==
y x!=
y x<>
y x is y x is not y x in s x not in s |
Comparison, identity, membership |
|
not x | boolean negation | |
x and y | boolean and | |
x or y | boolean or | |
lambda args : expr | anonymous function |
- Alternate names are defined in module operator (e.g.
__add__
andadd
for +) - Most operators are overridable
Basic types and their operations
<!-- COMPARISONS -->Comparisons (defined between any types)
< | strictly less than |
(1)
|
<= | less than or equal to | |
> | strictly greater than | |
>= | greater than or equal to | |
== | equal to | |
!= or <> | not equal to | |
is | object identity |
(2)
|
is not | negated object identity |
(2)
|
Notes :
- Comparison behavior can be overridden for a given class by defining special method __cmp__ .
- (1) X < Y < Z < W has expected meaning, unlike C
- (2) Compare object identities (i.e. id (object)), not object values.
None
<!-- BOOLEAN OPERATORS -->
None
is used as default return value on functions. Built-in single object with typeNoneType
. Might become a keyword in the future.- Input that evaluates to
None
does not print when running Python interactively.- None is now a constant ; trying to bind a value to the name "None" is now a syntax error.
Boolean operators
built-in bool (expr ) | True if expr is true, False otherwise. |
see True, False
|
None , numeric zeros, empty sequences and mappings | considered False | |
all other values | considered True | |
not x | True if x is False , else False | |
x or y | if x is False then y , else x |
(1)
|
x and y | if x is False then x , else y |
(1)
|
Notes :
- Truth testing behavior can be overridden for a given class by defining special method __nonzero__ .
- (1) Evaluate second arg only if necessary to determine outcome.
Numeric types
Floats, integers, long integers, Decimals .
<!-- OPERATORS ON ALL NUMERIC TYPES -->
- Floats (type
float
) are implemented with C doubles.- Integers (type
int
) are implemented with C longs (signed 32 bits, maximum value issys.maxint
)- Long integers (type
long
) have unlimited size (only limit is system resources).- Integers and long integers are unified starting from release 2.2 (the L suffix is no longer required).
int()
returns along
integer instead of raisingOverflowError
. Overflowing operations such as2<<32
no longer triggerFutureWarning
and return a long integer. Since 2.4, new typeDecimal
introduced (see module: decimal ) to compensate for some limitations of the floating point type, in particular with fractions. Unlike floats, decimal numbers can be represented exactly; exactness is preserved in calculations; precision is user settable via theContext
type [PEP 327 ].
Operators on all numeric types
abs (x ) | the absolute value of x |
int (x ) | x converted to integer |
long (x ) | x converted to long integer |
float (x ) | x converted to floating point |
-x | x negated |
+x | x unchanged |
x + y | the sum of x and y |
x - y | difference of x and y |
x * y | product of x and y |
x / y | true division of x by y: 1/2 -> 0.5 (1) |
x // y | floor division operator: 1//2 -> 0 (1) |
x % y | x modulo y |
divmod (x , y ) | the tuple (x //y , x %y ) |
x ** y | x to the power y (the same as pow (x ,y )) |
Notes :
- (1) /
is still a floor
division (1/2 == 0) unless validated by a
from __future__ import division
. - classes may override methods
__truediv__
and__floordiv__
to redefine these operators.
Bit operators on integers and long integers
~x | the bits of x inverted |
x ^ y | bitwise exclusive or of x and y |
x & y | bitwise and of x and y |
x | y | bitwise or of x and y |
x << n | x shifted left by n bits |
x >> n | x shifted right by n bits |
Complex Numbers
- Type
complex
, represented as a pair of machine-level double precision floating point numbers. - The real and imaginary value of a complex number z can be retrieved through the attributes z.real and z.imag .
Numeric exceptions
TypeError
OverflowError
ZeroDivisionError
Operations on all sequence types (lists, tuples, strings)
x in s |
True
if an item of s
is equal to x
,
else False
|
(3)
|
x not in s |
False
if an item of s
is equal to x
,
else True
|
(3)
|
s1 + s2 | the concatenation of s1 and s2 | |
s * n , n * s | n copies of s concatenated |
|
s [ i ] | i 'th item of s , origin 0 |
(1)
|
s
[
i
:
j
]
s [ i : j : step ] |
Slice of s from i (included) to j (excluded). Optional step value, possibly negative (default: 1). |
(1), (2)
|
len (s ) | Length of s | |
min (s ) | Smallest item of s |
|
max (s ) | Largest item of s |
|
reversed (s ) | [2.4] Returns an iterator
on s
in reverse order. s
must be a sequence, not an
iterator (use reversed(list(s))
in this case. [PEP 322]
|
|
sorted
(iterable
[, cmp
] [, cmp=cmpFct ] [, key=keyGetter ] [, reverse=bool ]) |
[2.4] works like the new in-place list.sort() , but sorts a new list created from the iterable . |
|
Notes :
- (1) if i or j is negative, the index is relative to the end of the string, ie len(s )+i or len(s )+j is substituted. But note that -0 is still 0.
- (2) The slice of s
from i
to j
is defined
as the sequence of items with index k
such that i<= k
< j
.
If i or j is greater than len(s ), use len(s ). If j is omitted, use len(s ). If i is greater than or equal to j , the slice is empty. - (3) For strings: before 2.3, x must be a single
character string; Since 2.3,
x in s
is True if x is a substring of s.
Operations on mutable sequences (type list
)
Notes :
- (1) Raises a
ValueError
exception when x is not found in s (i.e. out of range). - (2) The sort() method takes an optional argument
cmp
specifying a comparison function takings 2 list items and returning -1, 0, or 1 depending on whether the 1st argument is considered smaller than, equal to, or larger than the 2nd argument. Note that this slows the sorting process down considerably. Since 2.4, thecmp
argument may be specified as a keyword, and 2 optional keywords args are added:key
is a fct that takes a list item and returns the key to use in the comparison (faster thancmp
);reverse
: If True, reverse the sense of the comparison used.
Since Python 2.3, the sort is guaranteed "stable". This means that two entries with equal keys will be returned in the same order as they were input. For example, you can sort a list of people by name, and then sort the list by age, resulting in a list sorted by age where people with the same age are in name-sorted order. - (3) The
sort()
andreverse()
methods modify the list in place for economy of space when sorting or reversing a large list. They don't return the sorted or reversed list to remind you of this side effect. - (4) The
pop()
method is not supported by mutable sequence types other than lists. The optional argument i defaults to -1, so that by default the last item is removed and returned. - (5) Raises a
TypeError
when x is not a list object.
Operations on mappings /
dictionaries (type dict
)
len (d ) | The number of items in d | |
dict
() dict (**kwargs ) dict (iterable ) dict (d) |
Creates an empty dictionary. Creates a dictionary init with the keyword args kwargs . Creates a dictionary init with (key, value) pairs provided by iterable . Creates a dictionary which is a copy of dictionary d . |
|
d .fromkeys (iterable , value =None) | Class method to create a dictionary with keys provided by iterator , and all values set to value . | |
d [ k ] | The item of d with key k |
(1)
|
d [k ] = x | Set d [k ] to x | |
del d [k ] | Removes d [k ] from d |
(1)
|
d .clear () | Removes all items from d | |
d .copy () | A shallow copy of d | |
d
.has_key
(k
) k in d |
True
if d
has key k
, else False
|
|
d .items () | A copy of d 's list of (key, item) pairs |
(2)
|
d .keys () | A copy of d 's list of keys |
(2)
|
d1 .update (d2 ) |
for k, v in d2
.items(): d1
[k] = v
Since 2.4, update (**kwargs ) and update (iterable ) may also be used. |
|
d .values () | A copy of d 's list of values |
(2)
|
d .get (k , defaultval ) | The item of d with key k |
(3)
|
d .setdefault (k [,defaultval ]) | d [k ] if k in d , else defaultval (also setting it) |
(4)
|
d.iteritems () | Returns an iterator over (key, value) pairs . | |
d.iterkeys () | Returns an iterator over the mapping's keys . | |
d.itervalues () | Returns an iterator over the mapping's values . | |
d .pop (k [, default ]) | Removes key k
and returns the corresponding value. If key
is not found, default
is returned if given, otherwise KeyError
is raised. |
|
d .popitem () | Removes and returns an arbitrary (key, value) pair from d |
|
Notes :
-
TypeError
is raised if key is not acceptable. - (1)
KeyError
is raised if key k is not in the map. - (2) Keys and values are listed in random order.
- (3) Never raises an exception if k
is not in the map,
instead it returns defaultval
. defaultval
is optional,
when not provided and k
is not in the map,
None
is returned. - (4) Never raises an exception if k
is not
in the map, instead returns defaultVal
, and adds k
to
map with value defaultVal
. defaultVal
is optional.
When not provided and k
is not in the map,
None
is returned and added to map.
Operations
on strings (types str
& unicode
)
str
and unicode
types
share a common base class basestring
.s. capitalize () | Returns a copy of s with its first character capitalized, and the rest of the characters lowercased. | |
s. center (width [ , fillChar=' ' ] ) | Returns a copy of s centered in a string of length width , surrounded by the appropriate number of fillChar characters. |
(1)
|
s. count (sub [ , start [ , end ]] ) | Returns the number of occurrences of substring sub in string s . |
(2)
|
s. decode ( [ encoding [ , errors ]] ) | Returns a unicode
string representing the decoded
version of str
s
, using the given codec
(encoding). Useful when reading from a file or a I/O function that
handles only str
. Inverse of encode
. |
(3)
|
s. encode ( [ encoding [ , errors ]] ) | Returns a str
representing an encoded version of s
.
Mostly used to encode a unicode
string to a str
in order to print it or write it to a file (since these I/O functions
only accept str
), e.g. u'légère'.encode('utf8')
.
Also used to encode a str
to a str
, e.g. to
zip (codec 'zip') or uuencode (codec 'uu') it. Inverse of decode
.
|
(3)
|
s. endswith (suffix [ , start [ , end ]] ) | Returns True
if s
ends with the specified suffix
,
otherwise return false. Since 2.5 suffix
can also be a tuple
of strings to try.
|
(2)
|
s. expandtabs ( [ tabsize ] ) | Returns a copy of s where all tab characters are expanded using spaces. |
(4)
|
s. find (sub [ ,start [ ,end ]] ) | Returns the lowest index in s where substring sub is found. Returns -1 if sub is not found. |
(2)
|
s. index (sub [ , start [ , end ]] ) | like find()
, but raises ValueError
when the substring is not found. |
(2)
|
s. isalnum () | Returns True
if all characters in s
are
alphanumeric, False
otherwise. |
(5)
|
s. isalpha () | Returns True
if all characters in s
are
alphabetic, False
otherwise. |
(5)
|
s. isdigit () | Returns True
if all characters in s
are digit
characters, False
otherwise. |
(5)
|
s. islower () | Returns True
if all characters in s
are
lowercase, False
otherwise. |
(6)
|
s. isspace () | Returns True
if all characters in s
are
whitespace characters, False
otherwise. |
(5)
|
s. istitle () | Returns True
if string s
is a titlecased
string, False
otherwise. |
(7)
|
s. isupper () | Returns True
if all characters in s
are
uppercase, False
otherwise. |
(6)
|
separator. join (seq) | Returns a concatenation of the strings in the sequence seq
,
separated by string separator
, e.g.: ",".join(['A', 'B',
'C'])
-> "A,B,C"
|
|
s. ljust/rjust/center (width [, fillChar=' ' ] ) | Returns s
发表评论
|
相关推荐
安装完成后,可以通过命令行输入`python --version`或`python2.5 --version`来验证Python 2.5是否正确安装。 需要注意的是,尽管Python 2.5是一个经典版本,但它已经不再被官方维护,安全性和兼容性方面可能存在...
Python 2.5是Python编程语言的一个重要版本,发布于2006年,它引入了许多新特性,改进了已有的功能,并修复了一些错误。在这个版本中,开发者们可以享受到更强大、更高效的编程体验。以下是一些关于Python 2.5的关键...
Python 2.5是Python编程语言的一个重要版本,发布于2006年,它引入了许多新特性并改进了已有的功能。这个教程是专为学习和理解Python 2.5设计的,涵盖了广泛的主题,旨在帮助开发者充分利用这一版本的强大功能。 ...
标题中的“numpy免安装-python2.5”意味着我们将讨论如何在Python 2.5环境中无需正式安装过程就能使用NumPy库。NumPy是Python科学计算的核心库,提供了大量的数学和逻辑操作功能,尤其对于处理多维数组和矩阵非常...
"wxPython2.8 for python2.5" 这个标题表明我们正在讨论的是一个针对Python 2.5版本的wxPython库的特定构建,版本号为2.8。wxPython是一个流行的Python绑定库,它允许开发者使用Python语言来创建原生的图形用户界面...
Python 2.5 编译器是Python编程语言的一个历史版本,它在2006年发布,提供了许多对Python语言特性和库的改进。在这个版本中,开发者引入了新的功能,增强了性能,并修复了大量的bug。尽管Python 2.5已经不再支持,但...
标题“Python 2.5 学习笔记”直接指向我们讨论的核心内容是Python这门编程语言,在这里,我们关注的是Python的2.5版本。由于这个版本发布于2006年,属于较早的版本,但它依然在计算机编程历史上占有重要地位,是很多...
windows mysqldb for python2.5 in windows
Python 2.5 是 Python 编程语言的一个早期版本,主要针对Windows操作系统进行了优化。它在2006年发布,引入了许多改进和新特性,包括: 1. **增强的性能**:Python 2.5在性能方面有所提升,通过优化内部算法和数据...
### Python 2.5 Reference Card #### 1. Variable Types ##### 1.1 Numbers - **Integer and Long Integers:** - `42`: A regular integer. - `052`: An octal representation (equivalent to decimal 42). - ...
标题“Python 2.5 Virtual Machine”和描述“Python 2.5 Virtual Machine, PPT”表明了我们要讨论的是Python编程语言的版本2.5中的虚拟机机制。在Python的世界中,虚拟机是其执行代码的关键组成部分。虚拟机通常被...
这个"python2.5中英对照教程"显然是一个非常实用的学习资源,不仅帮助初学者掌握Python 2.5的基本语法和概念,还可以通过中英文对照来提升英语阅读能力。 在Python 2.5中,有几个关键的知识点是值得深入探讨的: 1...
在提供的描述中,“pywin32-217.win32-py2.5.exe”是一个针对Python 2.5版本的特定构建。这意味着它是为运行Python 2.5解释器的系统设计的,可能不兼容更高或更低版本的Python。版本号217表示这是该模块的一个特定...
"windows Python 2.5和3.3.rar" 是一个包含两个不同版本Python的压缩包,分别是Python 2.5和Python 3.3。这两个版本在Python的发展历史上具有重要意义。Python 2.5是2.x系列的一个较旧版本,发布于2006年,而Python ...
Python 2.5是Python编程语言的一个早期版本,发布于2006年,它包含了许多重要的特性和改进。在本文中,我们将深入探讨Python 2.5的主要特性、安装过程以及与现代Python版本的差异。 **Python 2.5 特性概述** 1. **...
在这个场景中,`python2.5` 配置 `pylot` 库需要依赖于 `wxPython`、`numpy` 和 `matplotlib` 这三个关键组件。下面将详细介绍这三个库以及如何在Python 2.5环境下安装和使用它们。 `wxPython` 是一个用Python语言...
先装python-2.5.1.msi(解释器) 再装pywin32-212.win32-py2.5.exe(编辑器) Windows下Python:http://www.python.org/download/(解释器/平台) http://sourceforge.net/projects/pywin32(编辑器)
在提供的文件名“pywin32-210.win32-py2.5.exe”中,我们可以看出这是pywin32的一个构建,版本号为210,适用于32位Windows系统和Python2.5。通过运行这个安装程序,你可以将缺失的win32com.client模块添加到你的...
可用于python2.5的P4python