python - Python脚本失败基于Web的功能
问题描述
这是我在stackoverflow上的第一篇文章,如果描述有点奇怪,很抱歉。我一直在尝试制作一个通过电子邮件(smtplib 模块)发送数据的 python 脚本,以及下载图像和文件等其他 Web 功能。它工作了很多次,但今天它突然停止工作。我尝试连接到另一个网络,运行不同的 WiFi 重置命令,但到目前为止没有任何效果。这些是我一直遇到的问题。是否有任何已知的修复程序不涉及每次重新启动我的机器?
更新:似乎代码仅在重新启动后一分钟前有效。
import smtplib, ssl
context = ssl.create_default_context()
print(-2)
with smtplib.SMTP_SSL("smtp.gmail.com", port, timeout=120, context=context) as server:
print(0)
server.login(self_mail, password)
print(2)
server.sendmail(self_mail, rec_email, dfjk)
print(3)
def iget(link, name):
img_data = requests.get(link).content
with open(name, 'wb') as handler:
handler.write(img_data)
iget(link, 'h.png')
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
解决方案
推荐阅读
- python - 遍历 DF 列的行并根据条件更改值
- r - 将观察结果转换为 PDF
- java - MapStruct - 嵌套映射
- javascript - 为什么最小化的javascript脚本以相同的顺序使用相同的变量名
- excel - 索引/匹配未找到某些值
- pandas - 如何在熊猫中绘制多年来每月数据的图表
- google-apps-script - 尝试获取 Paypal 新订阅者电子邮件的文本
- swift - 在 Xcode 中使用 Swift 在 iOS App 中添加音频控件
- javascript - 不同时区的 setHours
- javascript - 出于某种原因反应闪烁的“Line-through”样式