有没有办法通过输入提示创建Python列表?
我正在创建一个 Python 邮件列表,但在函数结束时遇到问题。
问题是,列表必须是这样的:
['[email protected]', '[email protected]', '[email protected]']
我当前的代码:
mailinputs = raw_input('Enter all mails with comma: ')
receivers = [mailinputs]
如果您输入:
'[email protected]', '[email protected]', '[email protected]'
会出现这样的错误:
Probe failed: Illegal envelope To: address (invalid domain name):
否则,如果您输入:
[email protected], [email protected], [email protected]
仅 [电子邮件受保护] 接收邮件。
我应该怎么办?
I'm creating a Python mailing List, but I had a problem at the end of function.
Problem is, the List must be like this:
['[email protected]', '[email protected]', '[email protected]']
My current code:
mailinputs = raw_input('Enter all mails with comma: ')
receivers = [mailinputs]
If you type:
'[email protected]', '[email protected]', '[email protected]'
An error comes up like this:
Probe failed: Illegal envelope To: address (invalid domain name):
Else, If you type:
[email protected], [email protected], [email protected]
Only [email protected] receives the mail.
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
raw_input()
的返回是一个字符串。您需要用逗号将其拆分,然后您将得到一个列表:因此在您的示例中:
可以执行另一个步骤来删除每封电子邮件之前/之后的任何空格:
The return of
raw_input()
is a string. You need to split it on the comma, then you'll get a list:So in your example:
Another step can be done to remove any whitespace before/after each email: