diff --git a/邮件批量发送脚本.py b/邮件批量发送脚本.py index 9ca0369..f722775 100644 --- a/邮件批量发送脚本.py +++ b/邮件批量发送脚本.py @@ -272,7 +272,7 @@ def main(): current = index index += 1 - recipient = recipients[current] + recipient = str(recipients[current]).strip() name = names[current] code = codes[current] mark = sents[current] @@ -386,17 +386,15 @@ def main(): progress = index / limit * 100 print('[信息] 当前进度:%.2f %%' % progress) - key = input('[????] 继续运行 (C) / 保存并退出 (s) / 不保存退出 (w): ') - if key in ['W', 'w']: return 0 - elif key in ['S', 's']: break - else: continue + if input('[????] 是否保存到文件?确定 (y) / 取消 (N): ') in ['Y', 'y']: + try: + print(f'[信息] 正在写入文件:{filepath}') + pandas.DataFrame.from_dict(data).to_excel(filepath, index=False, sheet_name='Sheet1') + except Exception as e: + print(f'[警告] 写入文件时发生了错误:{e}') - print(f'[信息] 正在写入文件:{filepath}') - try: - pandas.DataFrame.from_dict(data).to_excel(filepath, index=False, sheet_name='Sheet1') - except Exception as e: - print(f'[警告] 写入文件时发生了错误:{e}') - return 6 + if input('[????] 继续运行 (C) / 退出程序 (w): ') in ['W', 'w']: break + else: continue return 0