Python strings and arrays of bytes

When using Python to do network programming will inevitably encounter convert a string to the byte stream,Here we record the following commonly used methods:

First byte array to a string,That is str:

Then the string to a byte array:

Either the above two methods are possible。

Original article written by Gerber drop-off:R0uter's Blog » Python strings and arrays of bytes

Reproduced Please keep the source and description link:https://www.logcg.com/archives/1686.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *