TOCPython LiteralString Literal Draft for Information Only
ContentPython Bytes Literal
Python Bytes LiteralIn general, a bytes literal is also one type of string literal. Howeve, logically, a string literal is a sequences of characters with each character representing one single unit of a string literal, or a string literal of length 1. While a bytes literal is a sequences of integers with each integer representing one single byte having ASCII value between 0 and 255 of a bytes literal. However, bytes with a numeric value of 128 or greater must be expressed with escapes. In other words, a bytes literal may be considered as a list of integer which can be retrieved by indexDefinition of Python Bytes LiteralA bytes literal is a sequence of ASCII characters.bytesliteral::=bytesprefix(shortbytes | longbytes) bytesprefix::="b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB" shortbytes::="'" shortbytesitem* "'" | '"' shortbytesitem* '"' longbytes::="'''" longbytesitem* "'''" | '"""' longbytesitem* '"""' shortbytesitem::=shortbyteschar | bytesescapeseq longbytesitem::=longbyteschar | bytesescapeseq shortbyteschar::=<any ASCII character except "\" or newline or the quote> longbyteschar::=<any ASCII character except "\"> bytesescapeseq::="\" <any ASCII character> Features of Python BytesThe Python bytes of bytes literal in Python have some typical features.Python Bytes NotationPython bytes literal is also denoted by quotes. Since bytes literal shares the same denoting method with string literal, a bytes literal is always prefixed with a prefixPython Bytes CataloguePython bytes can be divided intoPython Bytes PrefixPython bytes Prefix is used to specify the rules to interpret the following bytes literal. Whitespace is not allowed between the bytes prefix and the rest of the bytes literal. The meanings of supported bytes prefixs are:Python Bytes CharactersThe Python bytes character set is any ASCII character. A bytes literal itself is a sequences of integers with each integer representing one single bytes having ASCII value between 0 and 255 of a bytes literal. However, bytes with a numeric value of 128 or greater must be expressed with escapes.Escape Sequences CharactersThe backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. The recognized escape sequences are:Python Bytearray LiteralSince bytes literal is an immutable array of bytes (PyString), bytearray literal is designed as a mutable counterpart to bytes literal. In other words, bytearray literal is a mutable array of bytes (PyBytes).Source and Reference
©sideway ID: 210100003 Last Updated: 1/3/2021 Revision: 0 Latest Updated Links
|
Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Reference 79 Computer Hardware 249 Software Application 213 Digitization 32 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 429 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019