1

I got an error by trying to do a simple base64 encoder. My file isn´t called bas64.py or anything related.

     datatoencode = input("Enter the data you want to encode: ")
     datatoencode_bytes = datatoencode.encode('ascii')
     encodedBytes = base64.b64encode(datatoencode_bytes)
     base64_datatoencode = encodedBytes.decode('ascii')
     print("Encoded data: " + base64_datatoencode) 
3
  • Sorry but obviusly i imported base64 Commented May 20, 2020 at 23:39
  • so this question is closed? Commented May 20, 2020 at 23:39
  • yes it is closed Commented May 20, 2020 at 23:45

1 Answer 1

1

Do you define a function called base64 in your module somewhere? You can either rename the function, or import the base64 module under an alias, like this: import base64 as b64. If you do the latter, don't forget to replace base64.b64encode by b64.b64encode.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much I just realized that my func was called "encodetobase64"
Is your problem solved? You can click the check mark next to my answer to mark it as accepted. If my answer wasn't completely the right story, you can add your own answer to explain what exactly you did to solve the problem and accept your own answer. That way people having similar problems in the future can see what they need to do if they find this page on Google!

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.