Changeset 88 for trunk/traducidos/stdlib.rst
- Timestamp:
- 19/07/09 09:38:12 (4 years ago)
- File:
-
- 1 edited
-
trunk/traducidos/stdlib.rst (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/traducidos/stdlib.rst
r41 r88 28 28 29 29 Las funciones integradas :func:`dir` y :func:`help` son útiles como ayudas 30 interactivas para trabaj r con módulos grandes como :mod:`os`::30 interactivas para trabajar con módulos grandes como :mod:`os`:: 31 31 32 32 >>> import os … … 171 171 máquina local) 172 172 173 173 ------------------- revisado hasta acá!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 174 174 .. _tut-dates-and-times: 175 175 176 Dates and Times 177 =============== 178 179 The :mod:`datetime` module supplies classes for manipulating dates and times in 180 both simple and complex ways. While date and time arithmetic is supported, the 181 focus of the implementation is on efficient member extraction for output 182 formatting and manipulation. The module also supports objects that are timezone 183 aware. :: 184 185 # dates are easily constructed and formatted 186 >>> from datetime import date 187 >>> now = date.today() 188 >>> now 189 datetime.date(2003, 12, 2) 190 >>> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.") 191 '12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.' 192 193 # dates support calendar arithmetic 194 >>> birthday = date(1964, 7, 31) 195 >>> age = now - birthday 196 >>> age.days 197 14368 176 Fechas y tiempos 177 ================ 178 179 El módulo :mod:`datetime` ofrece clases para manejar fechas y tiempos tanto de 180 manera simple como compleja. Aunque se soporta aritmética sobre fechas y 181 tiempos, el foco de la implementación es en la eficiente extracción de partes 182 para manejarlas o formatear la salida. El módulo también soporta objetos que 183 son conscientes de la zona horaria. :: 184 185 # las fechas son fácilmente construidas y formateadas 186 >>> from datetime import date 187 >>> hoy = date.today() 188 >>> hoy 189 datetime.date(2009, 7, 19) 190 191 # nos aseguramos de tener la info de localización correcta 192 >>> locale.setlocale(locale.LC_ALL, locale.getdefaultlocale()) 193 'es_ES.UTF8' 194 >>> hoy.strftime("%m-%d-%y. %d %b %Y es %A. hoy es %d de %B.") 195 '07-19-09. 19 jul 2009 es domingo. hoy es 19 de julio.' 196 197 # las fechas soportan aritmética de calendario 198 >>> nacimiento = date(1964, 7, 31) 199 >>> edad = hoy - nacimiento 200 >>> edad.days 201 14368 198 202 199 203 200 204 .. _tut-data-compression: 201 205 202 Data Compression 203 ================ 204 205 Common data archiving and compression formats are directly supported by modules206 including: :mod:`zlib`, :mod:`gzip`, :mod:`bz2`, :mod:`zipfile` and 207 : mod:`tarfile`. ::208 209 >>> import zlib210 >>> s = 'witch which has which witches wrist watch'211 >>> len(s)212 41213 >>> t = zlib.compress(s)214 >>> len(t)215 37216 >>> zlib.decompress(t)217 'witch which has which witches wrist watch'218 >>> zlib.crc32(s)219 226805979206 Compresión de datos 207 =================== 208 209 Los formatos para archivar y comprimir datos se soportan directamente con los 210 módulos: :mod:`zlib`, :mod:`gzip`, :mod:`bz2`, :mod:`zipfile` y :mod:`tarfile`. 211 :: 212 213 >>> import zlib 214 >>> s = 'witch which has which witches wrist watch' 215 >>> len(s) 216 41 217 >>> t = zlib.compress(s) 218 >>> len(t) 219 37 220 >>> zlib.decompress(t) 221 'witch which has which witches wrist watch' 222 >>> zlib.crc32(s) 223 226805979 220 224 221 225
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/python-tutorial/chrome/site/your_project_logo.png)