Neither is better than the other, they do exactly the same thing. However, using .encode()
and .decode()
is the more common way to do it. It is also compatible with Python 2.
More Related Contents:
- How to match a string to pattern “Foo-Bar”, where Bar can be any element of a list? [closed]
- Passing extra arguments through connect
- How to use string.replace() in python 3.x
- How to set sys.stdout encoding in Python 3?
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- csv.Error: iterator should return strings, not bytes
- Unsupported operand type(s) for +: ‘int’ and ‘str’ [duplicate]
- PySerial non-blocking read loop
- in selenium web driver how to choose the correct iframe
- `xrange(2**100)` -> OverflowError: long int too large to convert to int
- How do I change the string representation of a Python class? [duplicate]
- Tkinter grid_forget is clearing the frame
- Python regex for unicode capitalized words
- Django: OperationalError No Such Table
- Unpack dictionary from Pandas Column
- Backwards-compatible input calls in Python
- How to get Windows short file name in python?
- How to bind several key presses together in turtle graphics?
- What does the “yield” keyword do in Python?
- Class (Static) variables and methods in Python
- Why do I get a `NameError` (or `UnboundLocalError`) from using a named exception after the `except` block?
- Connect to serial from a PyQt GUI
- Python 3 gives wrong output when dividing two large numbers?
- tkinter program compiles with cx_Freeze but program will not launch
- not all arguments converted during string formatting.. NO % variables
- How to set Python3.5.2 as default Python version on CentOS?
- how to get text from within a tag, but ignore other child tags
- How to compute jaccard similarity from a pandas dataframe
- Size of a Python list in memory
- Which of the 4 ways to call super() in Python 3 to use?