Code conversion

Time:2021-12-1

Establishment date: May 3, 2020

Revision date: None

Relevant software information:

Win 10 Python 3.7.6

Note: please quote or change this article at will. Just indicate the source and author. The author does not guarantee that the content is absolutely correct. Please be responsible for any consequences

preface

Sort out all kinds of informationstrandbytesThe coding conversion of can’t think of too much at once. It may not be complete

introduce

Other parameters are not described in detail below,quoteas well asunquotecome fromurllib.parse

  1. str.encode(encoding='utf-8')

    Convert STR to bytes according to the specified encoding

  2. bytes.decode(encoding='utf-8')

    Convert bytes to STR according to the specified encoding

  3. bytes.hex()

    STR converting byte to hexadecimal number

  4. bytes.fromhex(str)

    Convert hexadecimal string to bytes

  5. quote(str | bytes)

    Convert bytes or STR to STR of URL encoding

  6. unquote(str)

    Convert STR of URL encoding to unicode str

  7. code'latin-1'

    Conversion between byte and char

code

Conversion between STR or bytes in six different formats

from urllib.parse import quote, unquote

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Jason Yang