【问题标题】:Python converted to .exe but the user needs to be able to edit filesPython 转换为 .exe 但用户需要能够编辑文件
【发布时间】:2019-08-01 23:53:17
【问题描述】:

我制作了一个脚本,它使用 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"

【问题讨论】:

  • details.py 只是数据,还是代码?
  • …不要转换它? (如果没有,说为什么不!)
  • details.py 只是两个变量,一个用于密码,一个用于电子邮件
  • 因为如果我不转换它,我想使用它的朋友需要安装 python 和 selenium
  • 更改您的代码,以便从配置文件或 Windows 注册表中读取密码和电子邮件。

标签: python selenium pip exe py2exe


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 2020-03-26
    • 2020-12-05
    • 1970-01-01
    相关资源
    最近更新 更多