Changeset 391 for python/trunk/Doc/tutorial/stdlib.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/tutorial/stdlib.rst
r2 r391 15 15 16 16 >>> import os 17 >>> os.system('time 0:02')18 019 17 >>> os.getcwd() # Return the current working directory 20 18 'C:\\Python26' 21 >>> os.chdir('/server/accesslogs') 19 >>> os.chdir('/server/accesslogs') # Change current working directory 20 >>> os.system('mkdir today') # Run the command mkdir in the system shell 21 0 22 22 23 23 Be sure to use the ``import os`` style instead of ``from os import *``. This … … 73 73 The :mod:`getopt` module processes *sys.argv* using the conventions of the Unix 74 74 :func:`getopt` function. More powerful and flexible command line processing is 75 provided by the :mod:` optparse` module.75 provided by the :mod:`argparse` module. 76 76 77 77 … … 146 146 147 147 There are a number of modules for accessing the internet and processing internet 148 protocols. Two of the simplest are :mod:`urllib2` for retrieving data from urls148 protocols. Two of the simplest are :mod:`urllib2` for retrieving data from URLs 149 149 and :mod:`smtplib` for sending mail:: 150 150 … … 279 279 self.assertEqual(average([20, 30, 70]), 40.0) 280 280 self.assertEqual(round(average([1, 5, 7]), 1), 4.3) 281 self.assertRaises(ZeroDivisionError, average, []) 282 self.assertRaises(TypeError, average, 20, 30, 70) 281 with self.assertRaises(ZeroDivisionError): 282 average([]) 283 with self.assertRaises(TypeError): 284 average(20, 30, 70) 283 285 284 286 unittest.main() # Calling from the command line invokes all tests
Note:
See TracChangeset
for help on using the changeset viewer.