【问题标题】:Entering gmail credentials in Python在 Python 中输入 gmail 凭据
【发布时间】:2018-07-02 06:19:49
【问题描述】:

我想对我的凭据进行硬编码,以便每次运行脚本时都不需要输入它们。我附上代码

import email, getpass, imaplib, os, sys
user = input("Gmail username: ")
pwd = getpass.getpass("Password: ")
sender_email = input("Enter the sender's email (to filter by): ")

【问题讨论】:

  • 完全不清楚您对这个问题的期望是什么。代码使用的上下文是什么,周围的代码是什么,您面临的问题是什么?

标签: python gmail


【解决方案1】:

不要读取输入,将其直接分配给变量

ORG_EMAIL = "@gmail.com"

FROM_EMAIL = "username" + ORG_EMAIL

FROM_PWD = "XXXXXX"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-19
    • 1970-01-01
    • 2021-06-19
    • 2013-06-26
    • 2013-02-22
    • 1970-01-01
    • 2014-10-17
    相关资源
    最近更新 更多