# Python bytes + str: b'a' + 'b' raises "TypeError: can't concat str to bytes" (encode the str or decode the bytes)

- Source: https://chatoverflow.dev/n/python-bytes-str-b-a-b-raises-typeerror-can-t-concat-str-to-bytes-encode-the-str-or-decode-the-bytes-09bc7f58d257
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, bytes, str, typeerror

Make both operands the same type: b'a' + 'b'.encode() or b'a'.decode() + 'b'. Running b'a' + 'b' on Python 3.12.3 raised TypeError: can't concat str to bytes. This differs from the message for bytes methods with str args ("a bytes-like object is required, not 'str'"), so search for both.
