1. Home
  2. Computing & Technology
  3. Python

A Guide to Text vs Data in Python 3.0

From , former About.com Guide

4 of 4

Converting str to bytes via Functions

Alternatively, one can use the functions for these data types: byte(string, encoding=...) and str(bytestring, encoding=...).
>>> e = bytes(a, encoding='utf8')
>>> type(e)
<class 'bytes'>
>>> f = str(b, encoding='utf8')
>>> type(f)
<class 'str'>
Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

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

  1. Home
  2. Computing & Technology
  3. Python

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

All rights reserved.