1. Home
  2. Computing & Technology
  3. Python
Python Blog

From Al Lukaszewski, for About.com

Converting str to bytes in Python 3.0 via Methods

Thursday February 19, 2009
Given the significant difference between text and data in Python 3.0, you will not go far in programming against the 3.0 standard without being able to convert between them. One simple method of converting between str and bytes is to use the methods available to each class. To encode str as bytes, use str.encode(). For bytes to str, use byte.decode(). See "Converting str to bytes via Methods" for more on how to use them and more on transitioning from 2.x to Python 3.0.
Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.