Check if a string is encoded in base64 using Python

前端 未结 10 2076
离开以前
离开以前 2021-02-05 01:56

Is there a good way to check if a string is encoded in base64 using Python?

10条回答
  •  猫巷女王i
    2021-02-05 02:31

    import base64
    import binascii
    
    try:
        base64.decodestring("foo")
    except binascii.Error:
        print "no correct base64"
    

提交回复
热议问题