當前位置: 首頁>>代碼示例>>Python>>正文


Python base64MIME.decode方法代碼示例

本文整理匯總了Python中email.base64MIME.decode方法的典型用法代碼示例。如果您正苦於以下問題:Python base64MIME.decode方法的具體用法?Python base64MIME.decode怎麽用?Python base64MIME.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email.base64MIME的用法示例。


在下文中一共展示了base64MIME.decode方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_decoded_payload

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_get_decoded_payload(self):
        eq = self.assertEqual
        msg = self._msgobj('msg_10.txt')
        # The outer message is a multipart
        eq(msg.get_payload(decode=True), None)
        # Subpart 1 is 7bit encoded
        eq(msg.get_payload(0).get_payload(decode=True),
           'This is a 7bit encoded message.\n')
        # Subpart 2 is quopri
        eq(msg.get_payload(1).get_payload(decode=True),
           '\xa1This is a Quoted Printable encoded message!\n')
        # Subpart 3 is base64
        eq(msg.get_payload(2).get_payload(decode=True),
           'This is a Base64 encoded message.')
        # Subpart 4 has no Content-Transfer-Encoding: header.
        eq(msg.get_payload(3).get_payload(decode=True),
           'This has no Content-Transfer-Encoding: header.\n') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:19,代碼來源:test_email.py

示例2: test_get_body_encoding_with_uppercase_charset

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_get_body_encoding_with_uppercase_charset(self):
        eq = self.assertEqual
        msg = Message()
        msg['Content-Type'] = 'text/plain; charset=UTF-8'
        eq(msg['content-type'], 'text/plain; charset=UTF-8')
        charsets = msg.get_charsets()
        eq(len(charsets), 1)
        eq(charsets[0], 'utf-8')
        charset = Charset(charsets[0])
        eq(charset.get_body_encoding(), 'base64')
        msg.set_payload('hello world', charset=charset)
        eq(msg.get_payload(), 'aGVsbG8gd29ybGQ=\n')
        eq(msg.get_payload(decode=True), 'hello world')
        eq(msg['content-transfer-encoding'], 'base64')
        # Try another one
        msg = Message()
        msg['Content-Type'] = 'text/plain; charset="US-ASCII"'
        charsets = msg.get_charsets()
        eq(len(charsets), 1)
        eq(charsets[0], 'us-ascii')
        charset = Charset(charsets[0])
        eq(charset.get_body_encoding(), Encoders.encode_7or8bit)
        msg.set_payload('hello world', charset=charset)
        eq(msg.get_payload(), 'hello world')
        eq(msg['content-transfer-encoding'], '7bit') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:27,代碼來源:test_email.py

示例3: test_get_decoded_payload

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_get_decoded_payload(self):
        eq = self.assertEqual
        msg = self._msgobj('msg_10.txt')
        # The outer message is a multipart
        eq(msg.get_payload(decode=True), None)
        # Subpart 1 is 7bit encoded
        eq(msg.get_payload(0).get_payload(decode=True),
           'This is a 7bit encoded message.\n')
        # Subpart 2 is quopri
        eq(msg.get_payload(1).get_payload(decode=True),
           '\xa1This is a Quoted Printable encoded message!\n')
        # Subpart 3 is base64
        eq(msg.get_payload(2).get_payload(decode=True),
           'This is a Base64 encoded message.')
        # Subpart 4 is base64 with a trailing newline, which
        # used to be stripped (issue 7143).
        eq(msg.get_payload(3).get_payload(decode=True),
           'This is a Base64 encoded message.\n')
        # Subpart 5 has no Content-Transfer-Encoding: header.
        eq(msg.get_payload(4).get_payload(decode=True),
           'This has no Content-Transfer-Encoding: header.\n') 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:23,代碼來源:test_email.py

示例4: test_get_decoded_uu_payload

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_get_decoded_uu_payload(self):
        eq = self.assertEqual
        msg = Message()
        msg.set_payload('begin 666 -\n+:&5L;&\\@=V]R;&0 \n \nend\n')
        for cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
            msg['content-transfer-encoding'] = cte
            eq(msg.get_payload(decode=True), 'hello world')
        # Now try some bogus data
        msg.set_payload('foo')
        eq(msg.get_payload(decode=True), 'foo') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:12,代碼來源:test_email.py

示例5: test_decode_bogus_uu_payload_quietly

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_decode_bogus_uu_payload_quietly(self):
        msg = Message()
        msg.set_payload('begin 664 foo.txt\n%<W1F=0000H \n \nend\n')
        msg['Content-Transfer-Encoding'] = 'x-uuencode'
        old_stderr = sys.stderr
        try:
            sys.stderr = sfp = StringIO()
            # We don't care about the payload
            msg.get_payload(decode=True)
        finally:
            sys.stderr = old_stderr
        self.assertEqual(sfp.getvalue(), '') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:14,代碼來源:test_email.py

示例6: test_broken_base64_payload

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_broken_base64_payload(self):
        x = 'AwDp0P7//y6LwKEAcPa/6Q=9'
        msg = Message()
        msg['content-type'] = 'audio/x-midi'
        msg['content-transfer-encoding'] = 'base64'
        msg.set_payload(x)
        self.assertEqual(msg.get_payload(decode=True), x) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:9,代碼來源:test_email.py

示例7: test_decode

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_decode(self):
        eq = self.assertEqual
        eq(quopriMIME.decode(''), '')
        eq(quopriMIME.decode('hello'), 'hello')
        eq(quopriMIME.decode('hello', 'X'), 'hello')
        eq(quopriMIME.decode('hello\nworld', 'X'), 'helloXworld') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:8,代碼來源:test_email.py

示例8: test_8bit_unicode_input

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_8bit_unicode_input(self):
        teststr = u'\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
        eq = self.assertEqual
        msg = MIMEText(teststr, _charset='utf-8')
        eq(msg.get_charset().output_charset, 'utf-8')
        eq(msg['content-type'], 'text/plain; charset="utf-8"')
        eq(msg.get_payload(decode=True), teststr.encode('utf-8')) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:9,代碼來源:test_email.py

示例9: test_decode

# 需要導入模塊: from email import base64MIME [as 別名]
# 或者: from email.base64MIME import decode [as 別名]
def test_decode(self):
        eq = self.assertEqual
        eq(base64MIME.decode(''), '')
        eq(base64MIME.decode('aGVsbG8='), 'hello')
        eq(base64MIME.decode('aGVsbG8=', 'X'), 'hello')
        eq(base64MIME.decode('aGVsbG8NCndvcmxk\n', 'X'), 'helloXworld') 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:8,代碼來源:test_email.py


注:本文中的email.base64MIME.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。