diff --git a/.gitignore b/.gitignore index 0c63e0d..0159cd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode/ .venv/ *.csv -*.bat \ No newline at end of file +*.bat +*.xlsx \ No newline at end of file diff --git a/邮件批量发送脚本.py b/邮件批量发送脚本.py index 77feae5..a53535a 100644 --- a/邮件批量发送脚本.py +++ b/邮件批量发送脚本.py @@ -43,12 +43,12 @@ def main(): workbook = pandas.read_excel(args.input) data = workbook.where(pandas.notnull(workbook), None).to_dict(orient='list') recipients = data.get(args.column_address, []) - codes = data.get(args.column_code, []) except Exception as e: print(f'[!!!!] 读取数据表失败:{e}') return 1 limit = len(recipients) + codes = data.setdefault(args.column_code, [None] * limit) sents = data.setdefault(args.column_sent, [None] * limit) print(f'[信息] 已读取联系人信息共 {limit} 条') @@ -171,7 +171,9 @@ def main(): while active and index < limit: recipient = recipients[index] code = codes[index] - occurrence = occurrences.setdefault(code, [0]) + + if not code: occurrence = [0] + else: occurrence = occurrences.setdefault(code, [0]) current = index index += 1