是否有 rfc822.AddressList 的未弃用等效项?
我需要像 rfc822.AddressList 这样的东西来将电子邮件的“TO”标头字段的内容解析为单独的地址。由于 rfc822 已被弃用,取而代之的是电子邮件包,我在那里寻找类似的东西,但找不到任何东西。有谁知道我应该用什么来代替?
谢谢!
I need something like rfc822.AddressList to parse, say, the content of the "TO" header field of an email into individual addresses. Since rfc822 is deprecated in favor of the email package, I looked for something similar there but couldn't find anything. Does anyone know what I'm supposed to use instead?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哦,这是 email.utils.getaddresses。只需确保使用列表来调用它即可。
Oh it's email.utils.getaddresses. Just make sure to call it with a list.
如果您愿意使用第三方模块,我将 Python 2.x 模块 rfc822 移植到 Python 3.x
https ://github.com/MarkNenadov/rfc822py3
尚未经过彻底测试。我鼓励您尝试一下,并让我知道它是如何工作的以及您是否遇到任何问题。
为了让你的代码在 Python 2 和 3 中都能工作,你可以使用我的 rfc822py3 模块并执行以下操作:
If you are open to using a third party module, I ported the Python 2.x module rfc822 to Python 3.x
https://github.com/MarkNenadov/rfc822py3
It hasn't been tested thoroughly yet. I encourage you to try it out and let me know how it works and whether you have any problems.
To make your code work in both Python 2 and 3 you can take my rfc822py3 module and do: