mirror of
https://github.com/HChaZZY/Random-Picker.git
synced 2025-12-06 10:33:50 +08:00
使用更安全的with替换原本数据库文件打开方式
This commit is contained in:
6
点名器.pyw
6
点名器.pyw
@@ -35,9 +35,9 @@ elim_rows = 1
|
||||
percent_override = True
|
||||
|
||||
try:
|
||||
excel_data = excel.open_workbook(filename)
|
||||
table = excel_data.sheets()[0]
|
||||
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
|
||||
with excel.open_workbook(filename) as excel_data:
|
||||
table = excel_data.sheets()[0]
|
||||
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
|
||||
except FileNotFoundError:
|
||||
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
|
||||
sys.exit()
|
||||
|
||||
Reference in New Issue
Block a user