doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
classmethod datetime.combine(date, time, tzinfo=self.tzinfo) Return a new datetime object whose date components are equal to the given date object’s, and whose time components are equal to the given time object’s. If the tzinfo argument is provided, its value is used to set the tzinfo attribute of the result, otherwi...
python.library.datetime#datetime.datetime.combine
datetime.ctime() Return a string representing the date and time: >>> from datetime import datetime >>> datetime(2002, 12, 4, 20, 30, 40).ctime() 'Wed Dec 4 20:30:40 2002' The output string will not include time zone information, regardless of whether the input is aware or naive. d.ctime() is equivalent to: time.cti...
python.library.datetime#datetime.datetime.ctime
datetime.date() Return date object with same year, month and day.
python.library.datetime#datetime.datetime.date
datetime.day Between 1 and the number of days in the given month of the given year.
python.library.datetime#datetime.datetime.day
datetime.dst() If tzinfo is None, returns None, else returns self.tzinfo.dst(self), and raises an exception if the latter doesn’t return None or a timedelta object with magnitude less than one day. Changed in version 3.7: The DST offset is not restricted to a whole number of minutes.
python.library.datetime#datetime.datetime.dst
datetime.fold In [0, 1]. Used to disambiguate wall times during a repeated interval. (A repeated interval occurs when clocks are rolled back at the end of daylight saving time or when the UTC offset for the current zone is decreased for political reasons.) The value 0 (1) represents the earlier (later) of the two mom...
python.library.datetime#datetime.datetime.fold
classmethod datetime.fromisocalendar(year, week, day) Return a datetime corresponding to the ISO calendar date specified by year, week and day. The non-date components of the datetime are populated with their normal default values. This is the inverse of the function datetime.isocalendar(). New in version 3.8.
python.library.datetime#datetime.datetime.fromisocalendar
classmethod datetime.fromisoformat(date_string) Return a datetime corresponding to a date_string in one of the formats emitted by date.isoformat() and datetime.isoformat(). Specifically, this function supports strings in the format: YYYY-MM-DD[*HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]] where * can match any sin...
python.library.datetime#datetime.datetime.fromisoformat
classmethod datetime.fromordinal(ordinal) Return the datetime corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. ValueError is raised unless 1 <= ordinal <= datetime.max.toordinal(). The hour, minute, second and microsecond of the result are all 0, and tzinfo is None.
python.library.datetime#datetime.datetime.fromordinal
classmethod datetime.fromtimestamp(timestamp, tz=None) Return the local date and time corresponding to the POSIX timestamp, such as is returned by time.time(). If optional argument tz is None or not specified, the timestamp is converted to the platform’s local date and time, and the returned datetime object is naive....
python.library.datetime#datetime.datetime.fromtimestamp
datetime.hour In range(24).
python.library.datetime#datetime.datetime.hour
datetime.isocalendar() Return a named tuple with three components: year, week and weekday. The same as self.date().isocalendar().
python.library.datetime#datetime.datetime.isocalendar
datetime.isoformat(sep='T', timespec='auto') Return a string representing the date and time in ISO 8601 format: YYYY-MM-DDTHH:MM:SS.ffffff, if microsecond is not 0 YYYY-MM-DDTHH:MM:SS, if microsecond is 0 If utcoffset() does not return None, a string is appended, giving the UTC offset: YYYY-MM-DDTHH:MM:SS.fffff...
python.library.datetime#datetime.datetime.isoformat
datetime.isoweekday() Return the day of the week as an integer, where Monday is 1 and Sunday is 7. The same as self.date().isoweekday(). See also weekday(), isocalendar().
python.library.datetime#datetime.datetime.isoweekday
datetime.max The latest representable datetime, datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzinfo=None).
python.library.datetime#datetime.datetime.max
datetime.microsecond In range(1000000).
python.library.datetime#datetime.datetime.microsecond
datetime.min The earliest representable datetime, datetime(MINYEAR, 1, 1, tzinfo=None).
python.library.datetime#datetime.datetime.min
datetime.minute In range(60).
python.library.datetime#datetime.datetime.minute
datetime.month Between 1 and 12 inclusive.
python.library.datetime#datetime.datetime.month
classmethod datetime.now(tz=None) Return the current local date and time. If optional argument tz is None or not specified, this is like today(), but, if possible, supplies more precision than can be gotten from going through a time.time() timestamp (for example, this may be possible on platforms supplying the C gett...
python.library.datetime#datetime.datetime.now
datetime.replace(year=self.year, month=self.month, day=self.day, hour=self.hour, minute=self.minute, second=self.second, microsecond=self.microsecond, tzinfo=self.tzinfo, *, fold=0) Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified. N...
python.library.datetime#datetime.datetime.replace
datetime.resolution The smallest possible difference between non-equal datetime objects, timedelta(microseconds=1).
python.library.datetime#datetime.datetime.resolution
datetime.second In range(60).
python.library.datetime#datetime.datetime.second
datetime.strftime(format) Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see strftime() and strptime() Behavior.
python.library.datetime#datetime.datetime.strftime
classmethod datetime.strptime(date_string, format) Return a datetime corresponding to date_string, parsed according to format. This is equivalent to: datetime(*(time.strptime(date_string, format)[0:6])) ValueError is raised if the date_string and format can’t be parsed by time.strptime() or if it returns a value whi...
python.library.datetime#datetime.datetime.strptime
datetime.time() Return time object with same hour, minute, second, microsecond and fold. tzinfo is None. See also method timetz(). Changed in version 3.6: The fold value is copied to the returned time object.
python.library.datetime#datetime.datetime.time
datetime.timestamp() Return POSIX timestamp corresponding to the datetime instance. The return value is a float similar to that returned by time.time(). Naive datetime instances are assumed to represent local time and this method relies on the platform C mktime() function to perform the conversion. Since datetime sup...
python.library.datetime#datetime.datetime.timestamp
datetime.timetuple() Return a time.struct_time such as returned by time.localtime(). d.timetuple() is equivalent to: time.struct_time((d.year, d.month, d.day, d.hour, d.minute, d.second, d.weekday(), yday, dst)) where yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1 is th...
python.library.datetime#datetime.datetime.timetuple
datetime.timetz() Return time object with same hour, minute, second, microsecond, fold, and tzinfo attributes. See also method time(). Changed in version 3.6: The fold value is copied to the returned time object.
python.library.datetime#datetime.datetime.timetz
classmethod datetime.today() Return the current local datetime, with tzinfo None. Equivalent to: datetime.fromtimestamp(time.time()) See also now(), fromtimestamp(). This method is functionally equivalent to now(), but without a tz parameter.
python.library.datetime#datetime.datetime.today
datetime.toordinal() Return the proleptic Gregorian ordinal of the date. The same as self.date().toordinal().
python.library.datetime#datetime.datetime.toordinal
datetime.tzinfo The object passed as the tzinfo argument to the datetime constructor, or None if none was passed.
python.library.datetime#datetime.datetime.tzinfo
datetime.tzname() If tzinfo is None, returns None, else returns self.tzinfo.tzname(self), raises an exception if the latter doesn’t return None or a string object,
python.library.datetime#datetime.datetime.tzname
classmethod datetime.utcfromtimestamp(timestamp) Return the UTC datetime corresponding to the POSIX timestamp, with tzinfo None. (The resulting object is naive.) This may raise OverflowError, if the timestamp is out of the range of values supported by the platform C gmtime() function, and OSError on gmtime() failure....
python.library.datetime#datetime.datetime.utcfromtimestamp
classmethod datetime.utcnow() Return the current UTC date and time, with tzinfo None. This is like now(), but returns the current UTC date and time, as a naive datetime object. An aware current UTC datetime can be obtained by calling datetime.now(timezone.utc). See also now(). Warning Because naive datetime objects ...
python.library.datetime#datetime.datetime.utcnow
datetime.utcoffset() If tzinfo is None, returns None, else returns self.tzinfo.utcoffset(self), and raises an exception if the latter doesn’t return None or a timedelta object with magnitude less than one day. Changed in version 3.7: The UTC offset is not restricted to a whole number of minutes.
python.library.datetime#datetime.datetime.utcoffset
datetime.utctimetuple() If datetime instance d is naive, this is the same as d.timetuple() except that tm_isdst is forced to 0 regardless of what d.dst() returns. DST is never in effect for a UTC time. If d is aware, d is normalized to UTC time, by subtracting d.utcoffset(), and a time.struct_time for the normalized ...
python.library.datetime#datetime.datetime.utctimetuple
datetime.weekday() Return the day of the week as an integer, where Monday is 0 and Sunday is 6. The same as self.date().weekday(). See also isoweekday().
python.library.datetime#datetime.datetime.weekday
datetime.year Between MINYEAR and MAXYEAR inclusive.
python.library.datetime#datetime.datetime.year
datetime.__format__(format) Same as datetime.strftime(). This makes it possible to specify a format string for a datetime object in formatted string literals and when using str.format(). For a complete list of formatting directives, see strftime() and strptime() Behavior.
python.library.datetime#datetime.datetime.__format__
datetime.__str__() For a datetime instance d, str(d) is equivalent to d.isoformat(' ').
python.library.datetime#datetime.datetime.__str__
datetime.MAXYEAR The largest year number allowed in a date or datetime object. MAXYEAR is 9999.
python.library.datetime#datetime.MAXYEAR
datetime.MINYEAR The smallest year number allowed in a date or datetime object. MINYEAR is 1.
python.library.datetime#datetime.MINYEAR
class datetime.time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0) All arguments are optional. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments must be integers in the following ranges: 0 <= hour < 24, 0 <= minute < 60, 0 <= second < 60, 0 <= microsecond < 1000...
python.library.datetime#datetime.time
time.dst() If tzinfo is None, returns None, else returns self.tzinfo.dst(None), and raises an exception if the latter doesn’t return None, or a timedelta object with magnitude less than one day. Changed in version 3.7: The DST offset is not restricted to a whole number of minutes.
python.library.datetime#datetime.time.dst
time.fold In [0, 1]. Used to disambiguate wall times during a repeated interval. (A repeated interval occurs when clocks are rolled back at the end of daylight saving time or when the UTC offset for the current zone is decreased for political reasons.) The value 0 (1) represents the earlier (later) of the two moments...
python.library.datetime#datetime.time.fold
classmethod time.fromisoformat(time_string) Return a time corresponding to a time_string in one of the formats emitted by time.isoformat(). Specifically, this function supports strings in the format: HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]] Caution This does not support parsing arbitrary ISO 8601 strings. It i...
python.library.datetime#datetime.time.fromisoformat
time.hour In range(24).
python.library.datetime#datetime.time.hour
time.isoformat(timespec='auto') Return a string representing the time in ISO 8601 format, one of: HH:MM:SS.ffffff, if microsecond is not 0 HH:MM:SS, if microsecond is 0 HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]], if utcoffset() does not return None HH:MM:SS+HH:MM[:SS[.ffffff]], if microsecond is 0 and utcoffset() does...
python.library.datetime#datetime.time.isoformat
time.max The latest representable time, time(23, 59, 59, 999999).
python.library.datetime#datetime.time.max
time.microsecond In range(1000000).
python.library.datetime#datetime.time.microsecond
time.min The earliest representable time, time(0, 0, 0, 0).
python.library.datetime#datetime.time.min
time.minute In range(60).
python.library.datetime#datetime.time.minute
time.replace(hour=self.hour, minute=self.minute, second=self.second, microsecond=self.microsecond, tzinfo=self.tzinfo, *, fold=0) Return a time with the same value, except for those attributes given new values by whichever keyword arguments are specified. Note that tzinfo=None can be specified to create a naive time ...
python.library.datetime#datetime.time.replace
time.resolution The smallest possible difference between non-equal time objects, timedelta(microseconds=1), although note that arithmetic on time objects is not supported.
python.library.datetime#datetime.time.resolution
time.second In range(60).
python.library.datetime#datetime.time.second
time.strftime(format) Return a string representing the time, controlled by an explicit format string. For a complete list of formatting directives, see strftime() and strptime() Behavior.
python.library.datetime#datetime.time.strftime
time.tzinfo The object passed as the tzinfo argument to the time constructor, or None if none was passed.
python.library.datetime#datetime.time.tzinfo
time.tzname() If tzinfo is None, returns None, else returns self.tzinfo.tzname(None), or raises an exception if the latter doesn’t return None or a string object.
python.library.datetime#datetime.time.tzname
time.utcoffset() If tzinfo is None, returns None, else returns self.tzinfo.utcoffset(None), and raises an exception if the latter doesn’t return None or a timedelta object with magnitude less than one day. Changed in version 3.7: The UTC offset is not restricted to a whole number of minutes.
python.library.datetime#datetime.time.utcoffset
time.__format__(format) Same as time.strftime(). This makes it possible to specify a format string for a time object in formatted string literals and when using str.format(). For a complete list of formatting directives, see strftime() and strptime() Behavior.
python.library.datetime#datetime.time.__format__
time.__str__() For a time t, str(t) is equivalent to t.isoformat().
python.library.datetime#datetime.time.__str__
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative. Only days, seconds and microseconds are stored internally. Arguments are converted to those units:...
python.library.datetime#datetime.timedelta
timedelta.max The most positive timedelta object, timedelta(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999).
python.library.datetime#datetime.timedelta.max
timedelta.min The most negative timedelta object, timedelta(-999999999).
python.library.datetime#datetime.timedelta.min
timedelta.resolution The smallest possible difference between non-equal timedelta objects, timedelta(microseconds=1).
python.library.datetime#datetime.timedelta.resolution
timedelta.total_seconds() Return the total number of seconds contained in the duration. Equivalent to td / timedelta(seconds=1). For interval units other than seconds, use the division form directly (e.g. td / timedelta(microseconds=1)). Note that for very large time intervals (greater than 270 years on most platform...
python.library.datetime#datetime.timedelta.total_seconds
class datetime.timezone(offset, name=None) The offset argument must be specified as a timedelta object representing the difference between the local time and UTC. It must be strictly between -timedelta(hours=24) and timedelta(hours=24), otherwise ValueError is raised. The name argument is optional. If specified it mu...
python.library.datetime#datetime.timezone
timezone.dst(dt) Always returns None.
python.library.datetime#datetime.timezone.dst
timezone.fromutc(dt) Return dt + offset. The dt argument must be an aware datetime instance, with tzinfo set to self.
python.library.datetime#datetime.timezone.fromutc
timezone.tzname(dt) Return the fixed value specified when the timezone instance is constructed. If name is not provided in the constructor, the name returned by tzname(dt) is generated from the value of the offset as follows. If offset is timedelta(0), the name is “UTC”, otherwise it is a string in the format UTC±HH:...
python.library.datetime#datetime.timezone.tzname
timezone.utc The UTC timezone, timezone(timedelta(0)).
python.library.datetime#datetime.timezone.utc
timezone.utcoffset(dt) Return the fixed value specified when the timezone instance is constructed. The dt argument is ignored. The return value is a timedelta instance equal to the difference between the local time and UTC. Changed in version 3.7: The UTC offset is not restricted to a whole number of minutes.
python.library.datetime#datetime.timezone.utcoffset
class datetime.tzinfo This is an abstract base class, meaning that this class should not be instantiated directly. Define a subclass of tzinfo to capture information about a particular time zone. An instance of (a concrete subclass of) tzinfo can be passed to the constructors for datetime and time objects. The latter...
python.library.datetime#datetime.tzinfo
tzinfo.dst(dt) Return the daylight saving time (DST) adjustment, as a timedelta object or None if DST information isn’t known. Return timedelta(0) if DST is not in effect. If DST is in effect, return the offset as a timedelta object (see utcoffset() for details). Note that DST offset, if applicable, has already been ...
python.library.datetime#datetime.tzinfo.dst
tzinfo.fromutc(dt) This is called from the default datetime.astimezone() implementation. When called from that, dt.tzinfo is self, and dt’s date and time data are to be viewed as expressing a UTC time. The purpose of fromutc() is to adjust the date and time data, returning an equivalent datetime in self’s local time....
python.library.datetime#datetime.tzinfo.fromutc
tzinfo.tzname(dt) Return the time zone name corresponding to the datetime object dt, as a string. Nothing about string names is defined by the datetime module, and there’s no requirement that it mean anything in particular. For example, “GMT”, “UTC”, “-500”, “-5:00”, “EDT”, “US/Eastern”, “America/New York” are all va...
python.library.datetime#datetime.tzinfo.tzname
tzinfo.utcoffset(dt) Return offset of local time from UTC, as a timedelta object that is positive east of UTC. If local time is west of UTC, this should be negative. This represents the total offset from UTC; for example, if a tzinfo object represents both time zone and DST adjustments, utcoffset() should return thei...
python.library.datetime#datetime.tzinfo.utcoffset
dbm — Interfaces to Unix “databases” Source code: Lib/dbm/__init__.py dbm is a generic interface to variants of the DBM database — dbm.gnu or dbm.ndbm. If none of these modules is installed, the slow-but-simple implementation in module dbm.dumb will be used. There is a third party interface to the Oracle Berkeley DB. ...
python.library.dbm
dumbdbm.close() Close the dumbdbm database.
python.library.dbm#dbm.dumb.dumbdbm.close
dumbdbm.sync() Synchronize the on-disk directory and data files. This method is called by the Shelve.sync() method.
python.library.dbm#dbm.dumb.dumbdbm.sync
exception dbm.dumb.error Raised on dbm.dumb-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.
python.library.dbm#dbm.dumb.error
dbm.dumb.open(filename[, flag[, mode]]) Open a dumbdbm database and return a dumbdbm object. The filename argument is the basename of the database file (without any specific extensions). When a dumbdbm database is created, files with .dat and .dir extensions are created. The optional flag argument can be: Value Me...
python.library.dbm#dbm.dumb.open
exception dbm.error A tuple containing the exceptions that can be raised by each of the supported modules, with a unique exception also named dbm.error as the first item — the latter is used when dbm.error is raised.
python.library.dbm#dbm.error
exception dbm.gnu.error Raised on dbm.gnu-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.
python.library.dbm#dbm.gnu.error
gdbm.close() Close the gdbm database.
python.library.dbm#dbm.gnu.gdbm.close
gdbm.firstkey() It’s possible to loop over every key in the database using this method and the nextkey() method. The traversal is ordered by gdbm’s internal hash values, and won’t be sorted by the key values. This method returns the starting key.
python.library.dbm#dbm.gnu.gdbm.firstkey
gdbm.nextkey(key) Returns the key that follows key in the traversal. The following code prints every key in the database db, without having to create a list in memory that contains them all: k = db.firstkey() while k != None: print(k) k = db.nextkey(k)
python.library.dbm#dbm.gnu.gdbm.nextkey
gdbm.reorganize() If you have carried out a lot of deletions and would like to shrink the space used by the gdbm file, this routine will reorganize the database. gdbm objects will not shorten the length of a database file except by using this reorganization; otherwise, deleted file space will be kept and reused as ne...
python.library.dbm#dbm.gnu.gdbm.reorganize
gdbm.sync() When the database has been opened in fast mode, this method forces any unwritten data to be written to the disk.
python.library.dbm#dbm.gnu.gdbm.sync
dbm.gnu.open(filename[, flag[, mode]]) Open a gdbm database and return a gdbm object. The filename argument is the name of the database file. The optional flag argument can be: Value Meaning 'r' Open existing database for reading only (default) 'w' Open existing database for reading and writing 'c' Open dat...
python.library.dbm#dbm.gnu.open
exception dbm.ndbm.error Raised on dbm.ndbm-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.
python.library.dbm#dbm.ndbm.error
dbm.ndbm.library Name of the ndbm implementation library used.
python.library.dbm#dbm.ndbm.library
ndbm.close() Close the ndbm database.
python.library.dbm#dbm.ndbm.ndbm.close
dbm.ndbm.open(filename[, flag[, mode]]) Open a dbm database and return a ndbm object. The filename argument is the name of the database file (without the .dir or .pag extensions). The optional flag argument must be one of these values: Value Meaning 'r' Open existing database for reading only (default) 'w' Op...
python.library.dbm#dbm.ndbm.open
dbm.open(file, flag='r', mode=0o666) Open the database file file and return a corresponding object. If the database file already exists, the whichdb() function is used to determine its type and the appropriate module is used; if it does not exist, the first module listed above that can be imported is used. The option...
python.library.dbm#dbm.open
dbm.whichdb(filename) This function attempts to guess which of the several simple database modules available — dbm.gnu, dbm.ndbm or dbm.dumb — should be used to open a given file. Returns one of the following values: None if the file can’t be opened because it’s unreadable or doesn’t exist; the empty string ('') if t...
python.library.dbm#dbm.whichdb
decimal — Decimal fixed point and floating point arithmetic Source code: Lib/decimal.py The decimal module provides support for fast correctly-rounded decimal floating point arithmetic. It offers several advantages over the float datatype: Decimal “is based on a floating-point model which was designed with people in m...
python.library.decimal
class decimal.BasicContext This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to ROUND_HALF_UP. All flags are cleared. All traps are enabled (treated as exceptions) except Inexact, Rounded, and Subnormal. Because many of the traps are enabled,...
python.library.decimal#decimal.BasicContext
class decimal.Clamped Altered an exponent to fit representation constraints. Typically, clamping occurs when an exponent falls outside the context’s Emin and Emax limits. If possible, the exponent is reduced to fit by adding zeros to the coefficient.
python.library.decimal#decimal.Clamped