Ignore:
Timestamp:
19/07/09 09:38:12 (4 years ago)
Author:
facundobatista
Message:

Un poco más.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/traducidos/stdlib.rst

    r41 r88  
    2828 
    2929Las funciones integradas :func:`dir` y :func:`help` son útiles como ayudas 
    30 interactivas para trabajr con módulos grandes como :mod:`os`:: 
     30interactivas para trabajar con módulos grandes como :mod:`os`:: 
    3131 
    3232   >>> import os 
     
    171171máquina local) 
    172172 
    173  
     173------------------- revisado hasta acá!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    174174.. _tut-dates-and-times: 
    175175 
    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 
     176Fechas y tiempos 
     177================ 
     178 
     179El módulo :mod:`datetime` ofrece clases para manejar fechas y tiempos tanto de 
     180manera simple como compleja.  Aunque se soporta aritmética sobre fechas y 
     181tiempos, el foco de la implementación es en la eficiente extracción de partes 
     182para manejarlas o formatear la salida.  El módulo también soporta objetos que 
     183son 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 
    198202 
    199203 
    200204.. _tut-data-compression: 
    201205 
    202 Data Compression 
    203 ================ 
    204  
    205 Common data archiving and compression formats are directly supported by modules 
    206 including: :mod:`zlib`, :mod:`gzip`, :mod:`bz2`, :mod:`zipfile` and 
    207 :mod:`tarfile`. :: 
    208  
    209    >>> import zlib 
    210    >>> s = 'witch which has which witches wrist watch' 
    211    >>> len(s) 
    212    41 
    213    >>> t = zlib.compress(s) 
    214    >>> len(t) 
    215    37 
    216    >>> zlib.decompress(t) 
    217    'witch which has which witches wrist watch' 
    218    >>> zlib.crc32(s) 
    219    226805979 
     206Compresión de datos 
     207=================== 
     208 
     209Los formatos para archivar y comprimir datos se soportan directamente con los 
     210mó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 
    220224 
    221225 
Note: See TracChangeset for help on using the changeset viewer.