1

I'm currently porting some code from Python 2.x to 3.x and I have come to a hitch. When I try to change:

base = unicode(base, FSENCODING, "replace")

to what I think 3 wants, which is:

base = str(base, FSENCODING, "replace")

it doesn't work saying that str can not decode. If I try:

base = b'\x80abc'.decode(base, FSENCODING, "replace")

I get an error saying that this can only take two arguments instead of the three that I have provided.

1
  • 2
    You should include the error message, and preferably the whole traceback. Commented Mar 12, 2013 at 9:00

2 Answers 2

1

Try:

base = b'\x80abc'.decode(FSENCODING, "replace")
Sign up to request clarification or add additional context in comments.

Comments

1
base = str(base, FSENCODING, "replace")

Is correct. You can also do:

base = base.decode(FSENCODING, "replace")

It's the same thing.

What is going wrong is impossible to say without the error message.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.