mirror of
https://github.com/python/cpython.git
synced 2024-12-05 15:54:17 +08:00
Incorporate suggestions from Aahz.
This commit is contained in:
parent
d25c1c6351
commit
b7a10d1bc5
@ -2,9 +2,6 @@
|
|||||||
\usepackage[T1]{fontenc}
|
\usepackage[T1]{fontenc}
|
||||||
|
|
||||||
% Things to do:
|
% Things to do:
|
||||||
% Add a section on file I/O
|
|
||||||
% Write a chapter entitled ``Some Useful Modules''
|
|
||||||
% --re, math+cmath
|
|
||||||
% Should really move the Python startup file info to an appendix
|
% Should really move the Python startup file info to an appendix
|
||||||
|
|
||||||
\title{Python Tutorial}
|
\title{Python Tutorial}
|
||||||
@ -4397,7 +4394,7 @@ operating system:
|
|||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
>>> import os
|
>>> import os
|
||||||
>>> os.system('copy /data/mydata.fil /backup/mydata.fil')
|
>>> os.system('time 0:02')
|
||||||
0
|
0
|
||||||
>>> os.getcwd() # Return the current working directory
|
>>> os.getcwd() # Return the current working directory
|
||||||
'C:\\Python24'
|
'C:\\Python24'
|
||||||
@ -4484,9 +4481,7 @@ The most direct way to terminate a script is to use \samp{sys.exit()}.
|
|||||||
|
|
||||||
The \ulink{\module{re}}{../lib/module-re.html}
|
The \ulink{\module{re}}{../lib/module-re.html}
|
||||||
module provides regular expression tools for advanced string processing.
|
module provides regular expression tools for advanced string processing.
|
||||||
When only simple capabilities are needed, string methods are preferred
|
For complex matching and manipulation, regular expressions offer succinct,
|
||||||
because they are easier to read and debug. However, for more
|
|
||||||
sophisticated applications, regular expressions can provide succinct,
|
|
||||||
optimized solutions:
|
optimized solutions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
@ -4497,6 +4492,13 @@ optimized solutions:
|
|||||||
'cat in the hat'
|
'cat in the hat'
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
When only simple capabilities are needed, string methods are preferred
|
||||||
|
because they are easier to read and debug:
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
>>> 'tea for too'.replace('too', 'two')
|
||||||
|
'tea for two'
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
\section{Mathematics\label{mathematics}}
|
\section{Mathematics\label{mathematics}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user