doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
bytes.isalpha() bytearray.isalpha() Return True if all bytes in the sequence are alphabetic ASCII characters and the sequence is not empty, False otherwise. Alphabetic ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. For example: >>> b'ABCabc'.isalpha()...
python.library.stdtypes#bytearray.isalpha
bytes.isascii() bytearray.isascii() Return True if the sequence is empty or all bytes in the sequence are ASCII, False otherwise. ASCII bytes are in the range 0-0x7F. New in version 3.7.
python.library.stdtypes#bytearray.isascii
bytes.isdigit() bytearray.isdigit() Return True if all bytes in the sequence are ASCII decimal digits and the sequence is not empty, False otherwise. ASCII decimal digits are those byte values in the sequence b'0123456789'. For example: >>> b'1234'.isdigit() True >>> b'1.23'.isdigit() False
python.library.stdtypes#bytearray.isdigit
bytes.islower() bytearray.islower() Return True if there is at least one lowercase ASCII character in the sequence and no uppercase ASCII characters, False otherwise. For example: >>> b'hello world'.islower() True >>> b'Hello world'.islower() False Lowercase ASCII characters are those byte values in the sequence b...
python.library.stdtypes#bytearray.islower
bytes.isspace() bytearray.isspace() Return True if all bytes in the sequence are ASCII whitespace and the sequence is not empty, False otherwise. ASCII whitespace characters are those byte values in the sequence b' \t\n\r\x0b\f' (space, tab, newline, carriage return, vertical tab, form feed).
python.library.stdtypes#bytearray.isspace
bytes.istitle() bytearray.istitle() Return True if the sequence is ASCII titlecase and the sequence is not empty, False otherwise. See bytes.title() for more details on the definition of “titlecase”. For example: >>> b'Hello World'.istitle() True >>> b'Hello world'.istitle() False
python.library.stdtypes#bytearray.istitle
bytes.isupper() bytearray.isupper() Return True if there is at least one uppercase alphabetic ASCII character in the sequence and no lowercase ASCII characters, False otherwise. For example: >>> b'HELLO WORLD'.isupper() True >>> b'Hello world'.isupper() False Lowercase ASCII characters are those byte values in the...
python.library.stdtypes#bytearray.isupper
bytes.join(iterable) bytearray.join(iterable) Return a bytes or bytearray object which is the concatenation of the binary data sequences in iterable. A TypeError will be raised if there are any values in iterable that are not bytes-like objects, including str objects. The separator between elements is the contents ...
python.library.stdtypes#bytearray.join
bytes.ljust(width[, fillbyte]) bytearray.ljust(width[, fillbyte]) Return a copy of the object left justified in a sequence of length width. Padding is done using the specified fillbyte (default is an ASCII space). For bytes objects, the original sequence is returned if width is less than or equal to len(s). Note T...
python.library.stdtypes#bytearray.ljust
bytes.lower() bytearray.lower() Return a copy of the sequence with all the uppercase ASCII characters converted to their corresponding lowercase counterpart. For example: >>> b'Hello World'.lower() b'hello world' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyz'. Upperc...
python.library.stdtypes#bytearray.lower
bytes.lstrip([chars]) bytearray.lstrip([chars]) Return a copy of the sequence with specified leading bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, the chars a...
python.library.stdtypes#bytearray.lstrip
static bytes.maketrans(from, to) static bytearray.maketrans(from, to) This static method returns a translation table usable for bytes.translate() that will map each character in from into the character at the same position in to; from and to must both be bytes-like objects and have the same length. New in version ...
python.library.stdtypes#bytearray.maketrans
bytes.partition(sep) bytearray.partition(sep) Split the sequence at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself or its bytearray copy, and the part after the separator. If the separator is not found, return a 3-tuple containing a copy of the origi...
python.library.stdtypes#bytearray.partition
bytes.removeprefix(prefix, /) bytearray.removeprefix(prefix, /) If the binary data starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original binary data: >>> b'TestHook'.removeprefix(b'Test') b'Hook' >>> b'BaseTestCase'.removeprefix(b'Test') b'BaseTestCase' The prefix may ...
python.library.stdtypes#bytearray.removeprefix
bytes.removesuffix(suffix, /) bytearray.removesuffix(suffix, /) If the binary data ends with the suffix string and that suffix is not empty, return bytes[:-len(suffix)]. Otherwise, return a copy of the original binary data: >>> b'MiscTests'.removesuffix(b'Tests') b'Misc' >>> b'TmpDirMixin'.removesuffix(b'Tests') b'...
python.library.stdtypes#bytearray.removesuffix
bytes.replace(old, new[, count]) bytearray.replace(old, new[, count]) Return a copy of the sequence with all occurrences of subsequence old replaced by new. If the optional argument count is given, only the first count occurrences are replaced. The subsequence to search for and its replacement may be any bytes-like...
python.library.stdtypes#bytearray.replace
bytes.rfind(sub[, start[, end]]) bytearray.rfind(sub[, start[, end]]) Return the highest index in the sequence where the subsequence sub is found, such that sub is contained within s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. The subsequence to search fo...
python.library.stdtypes#bytearray.rfind
bytes.rindex(sub[, start[, end]]) bytearray.rindex(sub[, start[, end]]) Like rfind() but raises ValueError when the subsequence sub is not found. The subsequence to search for may be any bytes-like object or an integer in the range 0 to 255. Changed in version 3.3: Also accept an integer in the range 0 to 255 as t...
python.library.stdtypes#bytearray.rindex
bytes.rjust(width[, fillbyte]) bytearray.rjust(width[, fillbyte]) Return a copy of the object right justified in a sequence of length width. Padding is done using the specified fillbyte (default is an ASCII space). For bytes objects, the original sequence is returned if width is less than or equal to len(s). Note ...
python.library.stdtypes#bytearray.rjust
bytes.rpartition(sep) bytearray.rpartition(sep) Split the sequence at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself or its bytearray copy, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty bytes or...
python.library.stdtypes#bytearray.rpartition
bytes.rsplit(sep=None, maxsplit=-1) bytearray.rsplit(sep=None, maxsplit=-1) Split the binary sequence into subsequences of the same type, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done, the rightmost ones. If sep is not specified or None, any subsequence consisting solely ...
python.library.stdtypes#bytearray.rsplit
bytes.rstrip([chars]) bytearray.rstrip([chars]) Return a copy of the sequence with specified trailing bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, the chars ...
python.library.stdtypes#bytearray.rstrip
bytes.split(sep=None, maxsplit=-1) bytearray.split(sep=None, maxsplit=-1) Split the binary sequence into subsequences of the same type, using sep as the delimiter string. If maxsplit is given and non-negative, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is no...
python.library.stdtypes#bytearray.split
bytes.splitlines(keepends=False) bytearray.splitlines(keepends=False) Return a list of the lines in the binary sequence, breaking at ASCII line boundaries. This method uses the universal newlines approach to splitting lines. Line breaks are not included in the resulting list unless keepends is given and true. For e...
python.library.stdtypes#bytearray.splitlines
bytes.startswith(prefix[, start[, end]]) bytearray.startswith(prefix[, start[, end]]) Return True if the binary data starts with the specified prefix, otherwise return False. prefix can also be a tuple of prefixes to look for. With optional start, test beginning at that position. With optional end, stop comparing a...
python.library.stdtypes#bytearray.startswith
bytes.strip([chars]) bytearray.strip([chars]) Return a copy of the sequence with specified leading and trailing bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, ...
python.library.stdtypes#bytearray.strip
bytes.swapcase() bytearray.swapcase() Return a copy of the sequence with all the lowercase ASCII characters converted to their corresponding uppercase counterpart and vice-versa. For example: >>> b'Hello World'.swapcase() b'hELLO wORLD' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijk...
python.library.stdtypes#bytearray.swapcase
bytes.title() bytearray.title() Return a titlecased version of the binary sequence where words start with an uppercase ASCII character and the remaining characters are lowercase. Uncased byte values are left unmodified. For example: >>> b'Hello world'.title() b'Hello World' Lowercase ASCII characters are those byt...
python.library.stdtypes#bytearray.title
bytes.translate(table, /, delete=b'') bytearray.translate(table, /, delete=b'') Return a copy of the bytes or bytearray object where all bytes occurring in the optional argument delete are removed, and the remaining bytes have been mapped through the given translation table, which must be a bytes object of length 2...
python.library.stdtypes#bytearray.translate
bytes.upper() bytearray.upper() Return a copy of the sequence with all the lowercase ASCII characters converted to their corresponding uppercase counterpart. For example: >>> b'Hello World'.upper() b'HELLO WORLD' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyz'. Upperc...
python.library.stdtypes#bytearray.upper
bytes.zfill(width) bytearray.zfill(width) Return a copy of the sequence left filled with ASCII b'0' digits to make a sequence of length width. A leading sign prefix (b'+'/ b'-') is handled by inserting the padding after the sign character rather than before. For bytes objects, the original sequence is returned if w...
python.library.stdtypes#bytearray.zfill
class bytes([source[, encoding[, errors]]]) Firstly, the syntax for bytes literals is largely the same as that for string literals, except that a b prefix is added: Single quotes: b'still allows embedded "double" quotes' Double quotes: b"still allows embedded 'single' quotes". Triple quoted: b'''3 single quotes''',...
python.library.stdtypes#bytes
class bytes([source[, encoding[, errors]]]) Return a new “bytes” object, which is an immutable sequence of integers in the range 0 <= x < 256. bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavior. Accordingly, constructor arguments are interprete...
python.library.functions#bytes
bytes.capitalize() bytearray.capitalize() Return a copy of the sequence with each byte interpreted as an ASCII character, and the first byte capitalized and the rest lowercased. Non-ASCII byte values are passed through unchanged. Note The bytearray version of this method does not operate in place - it always produ...
python.library.stdtypes#bytes.capitalize
bytes.center(width[, fillbyte]) bytearray.center(width[, fillbyte]) Return a copy of the object centered in a sequence of length width. Padding is done using the specified fillbyte (default is an ASCII space). For bytes objects, the original sequence is returned if width is less than or equal to len(s). Note The b...
python.library.stdtypes#bytes.center
bytes.count(sub[, start[, end]]) bytearray.count(sub[, start[, end]]) Return the number of non-overlapping occurrences of subsequence sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation. The subsequence to search for may be any bytes-like object or an integer in the ...
python.library.stdtypes#bytes.count
bytes.decode(encoding="utf-8", errors="strict") bytearray.decode(encoding="utf-8", errors="strict") Return a string decoded from the given bytes. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a Unicod...
python.library.stdtypes#bytes.decode
bytes.endswith(suffix[, start[, end]]) bytearray.endswith(suffix[, start[, end]]) Return True if the binary data ends with the specified suffix, otherwise return False. suffix can also be a tuple of suffixes to look for. With optional start, test beginning at that position. With optional end, stop comparing at that...
python.library.stdtypes#bytes.endswith
bytes.expandtabs(tabsize=8) bytearray.expandtabs(tabsize=8) Return a copy of the sequence where all ASCII tab characters are replaced by one or more ASCII spaces, depending on the current column and the given tab size. Tab positions occur every tabsize bytes (default is 8, giving tab positions at columns 0, 8, 16 a...
python.library.stdtypes#bytes.expandtabs
bytes.find(sub[, start[, end]]) bytearray.find(sub[, start[, end]]) Return the lowest index in the data where the subsequence sub is found, such that sub is contained in the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found. The subsequence to s...
python.library.stdtypes#bytes.find
classmethod fromhex(string) This bytes class method returns a bytes object, decoding the given string object. The string must contain two hexadecimal digits per byte, with ASCII whitespace being ignored. >>> bytes.fromhex('2Ef0 F1f2 ') b'.\xf0\xf1\xf2' Changed in version 3.7: bytes.fromhex() now skips all ASCII wh...
python.library.stdtypes#bytes.fromhex
hex([sep[, bytes_per_sep]]) Return a string object containing two hexadecimal digits for each byte in the instance. >>> b'\xf0\xf1\xf2'.hex() 'f0f1f2' If you want to make the hex string easier to read, you can specify a single character separator sep parameter to include in the output. By default between each byte. ...
python.library.stdtypes#bytes.hex
bytes.index(sub[, start[, end]]) bytearray.index(sub[, start[, end]]) Like find(), but raise ValueError when the subsequence is not found. The subsequence to search for may be any bytes-like object or an integer in the range 0 to 255. Changed in version 3.3: Also accept an integer in the range 0 to 255 as the subs...
python.library.stdtypes#bytes.index
bytes.isalnum() bytearray.isalnum() Return True if all bytes in the sequence are alphabetical ASCII characters or ASCII decimal digits and the sequence is not empty, False otherwise. Alphabetic ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. ASCII deci...
python.library.stdtypes#bytes.isalnum
bytes.isalpha() bytearray.isalpha() Return True if all bytes in the sequence are alphabetic ASCII characters and the sequence is not empty, False otherwise. Alphabetic ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. For example: >>> b'ABCabc'.isalpha()...
python.library.stdtypes#bytes.isalpha
bytes.isascii() bytearray.isascii() Return True if the sequence is empty or all bytes in the sequence are ASCII, False otherwise. ASCII bytes are in the range 0-0x7F. New in version 3.7.
python.library.stdtypes#bytes.isascii
bytes.isdigit() bytearray.isdigit() Return True if all bytes in the sequence are ASCII decimal digits and the sequence is not empty, False otherwise. ASCII decimal digits are those byte values in the sequence b'0123456789'. For example: >>> b'1234'.isdigit() True >>> b'1.23'.isdigit() False
python.library.stdtypes#bytes.isdigit
bytes.islower() bytearray.islower() Return True if there is at least one lowercase ASCII character in the sequence and no uppercase ASCII characters, False otherwise. For example: >>> b'hello world'.islower() True >>> b'Hello world'.islower() False Lowercase ASCII characters are those byte values in the sequence b...
python.library.stdtypes#bytes.islower
bytes.isspace() bytearray.isspace() Return True if all bytes in the sequence are ASCII whitespace and the sequence is not empty, False otherwise. ASCII whitespace characters are those byte values in the sequence b' \t\n\r\x0b\f' (space, tab, newline, carriage return, vertical tab, form feed).
python.library.stdtypes#bytes.isspace
bytes.istitle() bytearray.istitle() Return True if the sequence is ASCII titlecase and the sequence is not empty, False otherwise. See bytes.title() for more details on the definition of “titlecase”. For example: >>> b'Hello World'.istitle() True >>> b'Hello world'.istitle() False
python.library.stdtypes#bytes.istitle
bytes.isupper() bytearray.isupper() Return True if there is at least one uppercase alphabetic ASCII character in the sequence and no lowercase ASCII characters, False otherwise. For example: >>> b'HELLO WORLD'.isupper() True >>> b'Hello world'.isupper() False Lowercase ASCII characters are those byte values in the...
python.library.stdtypes#bytes.isupper
bytes.join(iterable) bytearray.join(iterable) Return a bytes or bytearray object which is the concatenation of the binary data sequences in iterable. A TypeError will be raised if there are any values in iterable that are not bytes-like objects, including str objects. The separator between elements is the contents ...
python.library.stdtypes#bytes.join
bytes.ljust(width[, fillbyte]) bytearray.ljust(width[, fillbyte]) Return a copy of the object left justified in a sequence of length width. Padding is done using the specified fillbyte (default is an ASCII space). For bytes objects, the original sequence is returned if width is less than or equal to len(s). Note T...
python.library.stdtypes#bytes.ljust
bytes.lower() bytearray.lower() Return a copy of the sequence with all the uppercase ASCII characters converted to their corresponding lowercase counterpart. For example: >>> b'Hello World'.lower() b'hello world' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyz'. Upperc...
python.library.stdtypes#bytes.lower
bytes.lstrip([chars]) bytearray.lstrip([chars]) Return a copy of the sequence with specified leading bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, the chars a...
python.library.stdtypes#bytes.lstrip
static bytes.maketrans(from, to) static bytearray.maketrans(from, to) This static method returns a translation table usable for bytes.translate() that will map each character in from into the character at the same position in to; from and to must both be bytes-like objects and have the same length. New in version ...
python.library.stdtypes#bytes.maketrans
bytes.partition(sep) bytearray.partition(sep) Split the sequence at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself or its bytearray copy, and the part after the separator. If the separator is not found, return a 3-tuple containing a copy of the origi...
python.library.stdtypes#bytes.partition
bytes.removeprefix(prefix, /) bytearray.removeprefix(prefix, /) If the binary data starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original binary data: >>> b'TestHook'.removeprefix(b'Test') b'Hook' >>> b'BaseTestCase'.removeprefix(b'Test') b'BaseTestCase' The prefix may ...
python.library.stdtypes#bytes.removeprefix
bytes.removesuffix(suffix, /) bytearray.removesuffix(suffix, /) If the binary data ends with the suffix string and that suffix is not empty, return bytes[:-len(suffix)]. Otherwise, return a copy of the original binary data: >>> b'MiscTests'.removesuffix(b'Tests') b'Misc' >>> b'TmpDirMixin'.removesuffix(b'Tests') b'...
python.library.stdtypes#bytes.removesuffix
bytes.replace(old, new[, count]) bytearray.replace(old, new[, count]) Return a copy of the sequence with all occurrences of subsequence old replaced by new. If the optional argument count is given, only the first count occurrences are replaced. The subsequence to search for and its replacement may be any bytes-like...
python.library.stdtypes#bytes.replace
bytes.rfind(sub[, start[, end]]) bytearray.rfind(sub[, start[, end]]) Return the highest index in the sequence where the subsequence sub is found, such that sub is contained within s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. The subsequence to search fo...
python.library.stdtypes#bytes.rfind
bytes.rindex(sub[, start[, end]]) bytearray.rindex(sub[, start[, end]]) Like rfind() but raises ValueError when the subsequence sub is not found. The subsequence to search for may be any bytes-like object or an integer in the range 0 to 255. Changed in version 3.3: Also accept an integer in the range 0 to 255 as t...
python.library.stdtypes#bytes.rindex
bytes.rjust(width[, fillbyte]) bytearray.rjust(width[, fillbyte]) Return a copy of the object right justified in a sequence of length width. Padding is done using the specified fillbyte (default is an ASCII space). For bytes objects, the original sequence is returned if width is less than or equal to len(s). Note ...
python.library.stdtypes#bytes.rjust
bytes.rpartition(sep) bytearray.rpartition(sep) Split the sequence at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself or its bytearray copy, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty bytes or...
python.library.stdtypes#bytes.rpartition
bytes.rsplit(sep=None, maxsplit=-1) bytearray.rsplit(sep=None, maxsplit=-1) Split the binary sequence into subsequences of the same type, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done, the rightmost ones. If sep is not specified or None, any subsequence consisting solely ...
python.library.stdtypes#bytes.rsplit
bytes.rstrip([chars]) bytearray.rstrip([chars]) Return a copy of the sequence with specified trailing bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, the chars ...
python.library.stdtypes#bytes.rstrip
bytes.split(sep=None, maxsplit=-1) bytearray.split(sep=None, maxsplit=-1) Split the binary sequence into subsequences of the same type, using sep as the delimiter string. If maxsplit is given and non-negative, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is no...
python.library.stdtypes#bytes.split
bytes.splitlines(keepends=False) bytearray.splitlines(keepends=False) Return a list of the lines in the binary sequence, breaking at ASCII line boundaries. This method uses the universal newlines approach to splitting lines. Line breaks are not included in the resulting list unless keepends is given and true. For e...
python.library.stdtypes#bytes.splitlines
bytes.startswith(prefix[, start[, end]]) bytearray.startswith(prefix[, start[, end]]) Return True if the binary data starts with the specified prefix, otherwise return False. prefix can also be a tuple of prefixes to look for. With optional start, test beginning at that position. With optional end, stop comparing a...
python.library.stdtypes#bytes.startswith
bytes.strip([chars]) bytearray.strip([chars]) Return a copy of the sequence with specified leading and trailing bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None, ...
python.library.stdtypes#bytes.strip
bytes.swapcase() bytearray.swapcase() Return a copy of the sequence with all the lowercase ASCII characters converted to their corresponding uppercase counterpart and vice-versa. For example: >>> b'Hello World'.swapcase() b'hELLO wORLD' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijk...
python.library.stdtypes#bytes.swapcase
bytes.title() bytearray.title() Return a titlecased version of the binary sequence where words start with an uppercase ASCII character and the remaining characters are lowercase. Uncased byte values are left unmodified. For example: >>> b'Hello world'.title() b'Hello World' Lowercase ASCII characters are those byt...
python.library.stdtypes#bytes.title
bytes.translate(table, /, delete=b'') bytearray.translate(table, /, delete=b'') Return a copy of the bytes or bytearray object where all bytes occurring in the optional argument delete are removed, and the remaining bytes have been mapped through the given translation table, which must be a bytes object of length 2...
python.library.stdtypes#bytes.translate
bytes.upper() bytearray.upper() Return a copy of the sequence with all the lowercase ASCII characters converted to their corresponding uppercase counterpart. For example: >>> b'Hello World'.upper() b'HELLO WORLD' Lowercase ASCII characters are those byte values in the sequence b'abcdefghijklmnopqrstuvwxyz'. Upperc...
python.library.stdtypes#bytes.upper
bytes.zfill(width) bytearray.zfill(width) Return a copy of the sequence left filled with ASCII b'0' digits to make a sequence of length width. A leading sign prefix (b'+'/ b'-') is handled by inserting the padding after the sign character rather than before. For bytes objects, the original sequence is returned if w...
python.library.stdtypes#bytes.zfill
exception BytesWarning Base class for warnings related to bytes and bytearray.
python.library.exceptions#BytesWarning
bz2 — Support for bzip2 compression Source code: Lib/bz2.py This module provides a comprehensive interface for compressing and decompressing data using the bzip2 compression algorithm. The bz2 module contains: The open() function and BZ2File class for reading and writing compressed files. The BZ2Compressor and BZ2Deco...
python.library.bz2
class bz2.BZ2Compressor(compresslevel=9) Create a new compressor object. This object may be used to compress data incrementally. For one-shot compression, use the compress() function instead. compresslevel, if given, must be an integer between 1 and 9. The default is 9. compress(data) Provide data to the compress...
python.library.bz2#bz2.BZ2Compressor
compress(data) Provide data to the compressor object. Returns a chunk of compressed data if possible, or an empty byte string otherwise. When you have finished providing data to the compressor, call the flush() method to finish the compression process.
python.library.bz2#bz2.BZ2Compressor.compress
flush() Finish the compression process. Returns the compressed data left in internal buffers. The compressor object may not be used after this method has been called.
python.library.bz2#bz2.BZ2Compressor.flush
class bz2.BZ2Decompressor Create a new decompressor object. This object may be used to decompress data incrementally. For one-shot compression, use the decompress() function instead. Note This class does not transparently handle inputs containing multiple compressed streams, unlike decompress() and BZ2File. If you n...
python.library.bz2#bz2.BZ2Decompressor
decompress(data, max_length=-1) Decompress data (a bytes-like object), returning uncompressed data as bytes. Some of data may be buffered internally, for use in later calls to decompress(). The returned data should be concatenated with the output of any previous calls to decompress(). If max_length is nonnegative, re...
python.library.bz2#bz2.BZ2Decompressor.decompress
eof True if the end-of-stream marker has been reached. New in version 3.3.
python.library.bz2#bz2.BZ2Decompressor.eof
needs_input False if the decompress() method can provide more decompressed data before requiring new uncompressed input. New in version 3.5.
python.library.bz2#bz2.BZ2Decompressor.needs_input
unused_data Data found after the end of the compressed stream. If this attribute is accessed before the end of the stream has been reached, its value will be b''.
python.library.bz2#bz2.BZ2Decompressor.unused_data
class bz2.BZ2File(filename, mode='r', *, compresslevel=9) Open a bzip2-compressed file in binary mode. If filename is a str or bytes object, open the named file directly. Otherwise, filename should be a file object, which will be used to read or write the compressed data. The mode argument can be either 'r' for readi...
python.library.bz2#bz2.BZ2File
peek([n]) Return buffered data without advancing the file position. At least one byte of data will be returned (unless at EOF). The exact number of bytes returned is unspecified. Note While calling peek() does not change the file position of the BZ2File, it may change the position of the underlying file object (e.g....
python.library.bz2#bz2.BZ2File.peek
bz2.compress(data, compresslevel=9) Compress data, a bytes-like object. compresslevel, if given, must be an integer between 1 and 9. The default is 9. For incremental compression, use a BZ2Compressor instead.
python.library.bz2#bz2.compress
bz2.decompress(data) Decompress data, a bytes-like object. If data is the concatenation of multiple compressed streams, decompress all of the streams. For incremental decompression, use a BZ2Decompressor instead. Changed in version 3.3: Support for multi-stream inputs was added.
python.library.bz2#bz2.decompress
bz2.open(filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None) Open a bzip2-compressed file in binary or text mode, returning a file object. As with the constructor for BZ2File, the filename argument can be an actual filename (a str or bytes object), or an existing file object to read from o...
python.library.bz2#bz2.open
calendar — General calendar-related functions Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European co...
python.library.calendar
class calendar.Calendar(firstweekday=0) Creates a Calendar object. firstweekday is an integer specifying the first day of the week. 0 is Monday (the default), 6 is Sunday. A Calendar object provides several methods that can be used for preparing the calendar data for formatting. This class doesn’t do any formatting i...
python.library.calendar#calendar.Calendar
calendar.calendar(year, w=2, l=1, c=6, m=3) Returns a 3-column calendar for an entire year as a multi-line string using the formatyear() of the TextCalendar class.
python.library.calendar#calendar.calendar
itermonthdates(year, month) Return an iterator for the month month (1–12) in the year year. This iterator will return all days (as datetime.date objects) for the month and all days before the start of the month or after the end of the month that are required to get a complete week.
python.library.calendar#calendar.Calendar.itermonthdates
itermonthdays(year, month) Return an iterator for the month month in the year year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will simply be day of the month numbers. For the days outside of the specified month, the day number is 0.
python.library.calendar#calendar.Calendar.itermonthdays
itermonthdays2(year, month) Return an iterator for the month month in the year year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will be tuples consisting of a day of the month number and a week day number.
python.library.calendar#calendar.Calendar.itermonthdays2
itermonthdays3(year, month) Return an iterator for the month month in the year year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will be tuples consisting of a year, a month and a day of the month numbers. New in version 3.7.
python.library.calendar#calendar.Calendar.itermonthdays3
itermonthdays4(year, month) Return an iterator for the month month in the year year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will be tuples consisting of a year, a month, a day of the month, and a day of the week numbers. New in version 3.7.
python.library.calendar#calendar.Calendar.itermonthdays4
iterweekdays() Return an iterator for the week day numbers that will be used for one week. The first value from the iterator will be the same as the value of the firstweekday property.
python.library.calendar#calendar.Calendar.iterweekdays
monthdatescalendar(year, month) Return a list of the weeks in the month month of the year as full weeks. Weeks are lists of seven datetime.date objects.
python.library.calendar#calendar.Calendar.monthdatescalendar