Python 转换为 .exe 但用户需要能够编辑文件

标签 python selenium pip exe py2exe

我制作了一个使用 Selenium 自动化某些流程的脚本,以及另一个存储密码和电子邮件等变量的脚本。

我将其转换为 .exe 文件,但用户需要能够编辑 Details.py 文件。

是否有任何解决办法,因为一旦我将其转换为 .exe,我就无法编辑和保存文件?

编辑:发布代码以帮助回答:

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from Details import *

driver = webdriver.Firefox()

url = "https://discordapp.com/channels/530588470905929729/538868623981412362"
driver.get(url)
email = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@type='email']")))
email.send_keys(Email)

password = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@type='password']")))
password.send_keys(Password + Keys.ENTER)

sleep(5)

textbox = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//textarea[@placeholder='Message #bot-commands']")))
textbox.send_keys("!work" + Keys.ENTER)

sleep(30)

driver.quit()

这是Details.py:

Password = "Password"
Email = "mail@mail.com"

最佳答案

您需要重新考虑程序的设计。编辑 .py 文件以更改保存的凭据既不安全也不用户友好。我建议您查看一下已经行之有效的存储敏感信息的方法。有很多选择,您可以从 this post 开始.

关于Python 转换为 .exe 但用户需要能够编辑文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57318341/

相关文章:

python - 如何使用 QWebEngineView 打开下载文件对话框?

python - 将 scipy.optimize 用于非代数函数

python - 为什么 PyCharm 无法找到正确版本的 pip 来安装 Python 模块?

python - 没有名为 unidecode 的模块

python Pandas : How to replace values in a Dataframe based on another array in conditional base

python - Python 函数中的类型错误

selenium - 确认 WebdriverIO 中的 Chrome 导航对话框

google-chrome - Selenium WebDriverException : unknown error: call function result missing 'value' while calling sendkeys method

java - 如何在 Java 中创建 XML 属性文件?

heroku - heroku Flask webapp 部署中的requirements.txt vs Pipfile?