#๐Ÿ”’ Codecs Modules, Unable to get expected output.

17 messages ยท Page 1 of 1 (latest)

winged dew
#

https://paste.pythondiscord.com/QU5A

I'm trying to understand the codecs module to see If I can create a program to decode and encode any input with the functionally of dynamically choose what type to decode/encode you use but I'm having an issue on understand the instruction on using the codecs module. I looked at some examples of converting strings like hex which was a success but when I tried with other decoding type like base64.

lofty ridgeBOT
#

@winged dew

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

valid lantern
#

You're not supposed to pass a string there.

#

@winged dew

#

@winged dew Here is the part of that traceback that tells you what you did incorrectly.

#

Usually you will get a TypeError or similar when it expects one thing but doesn't get it.

winged dew
#

Why did it work for when I did it on a hex?

#

@valid lantern

valid lantern
#

How are you running the program when you give it the hex input?

winged dew
#

it outputted b'hello'

valid lantern
#

When you run the program with the base64 input how do you run it @winged dew ?

#

That's the output of your script after I told it to print(type(input_decode))

winged dew
#

Yeah. I'm ok if it output as a byte. Its just weird that it works on the decoding hex input but not base64 input unless the input need to be pass as a byte.

lofty ridgeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.