Remove the new line “\n” from base64 encoded strings in Python3?

后端 未结 4 2113
感情败类
感情败类 2021-02-05 03:15

I\'m trying to make a HTTPS connection in Python3 and when I try to encode my username and password the base64 encodebytes method returns the encoded v

4条回答
  •  时光取名叫无心
    2021-02-05 04:15

    I concur with Mandar's observation that base64.xxxx_encode() would produce output without line wrap \n.

    For those who want a more confident understanding than merely an observation, these are the official promise (sort of), that I can find on this topic. The Python 3 documentation does mention base64.encode(...) would add newlines after every 76 bytes of output. Comparing to that, all other *_encode(...) functions do not mention their linewrap behavior at all, which can argurably be considered as "no line wrap behavior". For what it's worth, the Python 2 documentation does not mention anything about line wrap at all.

提交回复
热议问题