当前位置:   article > 正文

pythonmessage用法_Python Message.Message方法代碼示例

message+= python

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

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

示例1: test_getset_charset

​點讚 6

# 需要導入模塊: from email import Message [as 別名]

# 或者: from email.Message import Message [as 別名]

def test_getset_charset(self):

eq = self.assertEqual

msg = Message()

eq(msg.get_charset(), None)

charset = Charset('iso-8859-1')

msg.set_charset(charset)

eq(msg['mime-version'], '1.0')

eq(msg.get_content_type(), 'text/plain')

eq(msg['content-type'], 'text/plain; charset="iso-8859-1"')

eq(msg.get_param('charset'), 'iso-8859-1')

eq(msg['content-transfer-encoding'], 'quoted-printable')

eq(msg.get_charset().input_charset, 'iso-8859-1')

# Remove the charset

msg.set_charset(None)

eq(msg.get_charset(), None)

eq(msg['content-type'], 'text/plain')

# Try adding a charset when there's already MIME headers present

msg = Message()

msg['MIME-Version'] = '2.0'

msg['Content-Type'] = 'text/x-weird'

msg['Content-Transfer-Encoding'] = 'quinted-puntable'

msg.set_charset(charset)

eq(msg['mime-version'], '2.0')

eq(msg['content-type'], 'text/x-weird; charset="iso-8859-1"')

eq(msg['content-transfer-encoding'], 'quinted-puntable')

開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,

示例2: test_set_param

​點讚 6

# 需要導入模塊: from email import Message [as 別名]

# 或者: from email.Message import Message [as 別名]

def test_set_param(self):

eq = self.assertEqual

msg = Message()

msg.set_param('charset', 'iso-2022-jp')

eq(msg.get_param('charset'), 'iso-2022-jp')

msg.set_param('importance', 'high value')

eq(msg.get_param('importance'), 'high value')

eq(msg.get_param('importance', unquote=False), '"high value"')

eq(msg.get_params(), [('text/plain', ''),

('charset', 'iso-2022-jp'),

('importance', 'high value')])

eq(msg.get_params(unquote=False), [('text/plain', ''),

('charset', '"iso-2022-jp"'),

('importance', '"high value"')])

msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy')

eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')

開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,

示例3: test_replace_header

​點讚 6

# 需要導入模塊: from email import Message [as 別名]

# 或者: from email.Message import Message [as 別名]

def test_replace_header(self):

eq = self.assertEqual

msg = Message()

msg.add_header('First', 'One')

msg.add_header('Second', 'Two')

msg.add_header('Third', 'Three')

eq(msg.keys(), ['First', 'Second', 'Third'])

eq(msg.values(), ['One', 'Two', 'Three'])

msg.replace_header('Second', 'Twenty')

eq(msg.keys(), ['First', 'Second', 'Third'])

eq(msg.values(), ['One', 'Twenty', 'Three'])

msg.add_header('First', 'Eleven')

msg.replace_header('First', 'One Hundred')

eq(msg.keys(), ['First', 'Second', 'Third', 'First'])

eq(msg.values(), ['One Hundred', 'Twenty', 'Three', 'Eleven'])

self.assertRaises(KeyError, msg.replace_header, 'Fourth&#

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/756673
推荐阅读
相关标签
  

闽ICP备14008679号