Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Python 3 for instructions encoded string conversion     - How to clear the DNS query cache under Linux / Unix / Mac (Linux)

- Change the kernel boot sequence after CentOS 7 kernel upgrade (Linux)

- RMAN backup file is much larger than the size of the database Cause Analysis (Database)

- VNC configuration detailed analysis under Linux (Linux)

- Java memory mechanism Description (Programming)

- Ten correct use Redis skills (Database)

- After CentOS configure SSH password Free, still prompted for a password (Linux)

- Use Pylint regulate your Python code (Programming)

- Android Custom View password box example (Programming)

- Linux system man help tips (Linux)

- Share Java-based multithreading file case (Programming)

- SSH Filesystem use a secure connection for network file system (Linux)

- Python programming style (Programming)

- Linux system Perl Lite netstat (Linux)

- Oracle 11g to create a second instance on Linux (Database)

- Android realize RippleEffect water (Programming)

- Python pickle module for simple use notes (Programming)

- In addition to wget and curl, what better alternatives (Linux)

- Install Jetty on CentOS / RHEL 6.X (Server)

- MySQL event table to achieve timing build a small note (Database)

  Python 3 for instructions encoded string conversion
  Add Date : 2018-11-21      
  Python 3 most important new feature probably be the text and binary data made clearer distinction. Text always Unicode, represented by the str type binary data type represented by bytes. Python 3 will not in any way an implicit mix str and bytes, so the distinction is this particularly clear. You can not concatenate strings and byte packet can not bag the search string in bytes (or vice versa), nor can the string passed to the function parameter byte packet (or vice versa). This is a good thing.

String can be encoded into a byte packets, and byte packet can be decoded into a string.

>>> '20'.encode (' utf-8 ')
b '\ xe2 \ x82 \ xac20'
>>> B '\ xe2 \ x82 \ xac20'.decode (' utf-8 ')

To look at this question so: the string is an abstract representation of text. A string of characters, the character is an abstract entity that has nothing to with any particular binary. In operation the string, we live in happy ignorance. We can string segmentation and fragmentation, and the search string can be spliced. We do not care how they are represented internally, each character in the string to use to save a few bytes. Only in the string into byte code package (for example, to send them on the channel) or (reverse), we will begin to pay attention to this point from the byte packet decoding string.

Incoming encode and decode parameters are encoded (or codec). Encoding is a binary data representation of an abstract character mode. There are many encoding. UTF-8 given above is one of the following is another:

>>> '20'.encode (' iso-8859-15 ')
b '\ xa420'
>>> B '\ xa420'.decode (' iso-8859-15 ')

This encoding is a vital part of the conversion process. From the coding, bytes objects b '\ xa420' just a bunch of bits only. Coding giving it meaning. Different coding, meaning this pile of bits will be a big difference:

>>> B '\ xa420'.decode (' windows-1255 ')
- To control based on IP address routing policy under Linux (Linux)
- PSUADE installation under Linux (Linux)
- MySQL display operation control tips (Database)
- Linux Log (Linux)
- Linux shell script to adjust the Task Scheduler (Linux)
- Using Maven to download Spring (Linux)
- Java concurrent programming using the synchronized keyword ReentrantLock alternative primitive (Programming)
- Python objects (Programming)
- Sublime Text 3 best features, plug-ins and settings (Linux)
- Windows 8.1 hard drive to install Ubuntu 14.04 dual system reference tutorials and multi-drive Precautions (Linux)
- grep command Detailed and relevant examples (Linux)
- OGG-03510 Problem (Database)
- Oracle table space create large files (Database)
- Oracle Migration partition table (Database)
- Linux Tutorial Share: How to sudo command to define the PATH environment variable (Linux)
- Ubuntu uses conky add desktop control (Linux)
- Ubuntu 15.04 / 14.04 install Ubuntu After Install 2.6 (Linux)
- CentOS install video converter FFmpeg and cutting tools segmenter (Linux)
- Linux how to prohibit the use of Ping command (Linux)
- Install JDK 1.7 + Eclipse in CentOS 6.4 in (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.