python - 使用批处理脚本调用读取 mbox 文件的 python 脚本
问题描述
我有这个代码,它将文件路径作为参数mbox
并打印最后一个 mbox 文件。
import mailbox
import sys
messages = mailbox.mbox(sys.argv[1])
print(messages[len(messages)-1])
我想.bat
在 Windows 中使用脚本调用这个脚本,所以我使用了以下代码,但它给了我这个错误
KeyError:没有带有密钥的消息:-1
这是我使用的脚本:
@echo off
set VAR_1= "C:\Users\hmk\Desktop\PFE 2019\ML\MachineLearningPhishing-master\MachineLearningPhishing-master\code\resources\email-enron.mbox"
python get_last_mail.py %1 VAR_1
pause
我在 jupyter notebook 上使用了相同的代码,只有文件路径的静态条目,它可以工作。
解决方案
推荐阅读
- ruby-on-rails - 如何在rails中传递和获取多个参数?
- php - 运行事务时出现 SQL 语法错误,但是将相同的 SQL 直接插入 phpmyadmin 时它可以工作
- python - 如何从不同的for循环写入文件到一个f.write
- javascript - 需要帮助将加密逻辑从 Js 转换为 Java
- apache-kafka - 如何用 Kafka 生成连续编号的消息?
- python - 如何跨文件共享python实例?
- r - 如何将使用 ComplexHeatmap 包创建的热图保存为 png 格式?
- ubuntu-16.04 - Zabbix 从 4.0.21 升级到 5.2 mysqlversion 错误
- c# - 在字节中间设置 3 位 C#(按位运算符)
- javascript - 如何对所有列表(数组)项目进行操作?