RecursionError: превышена максимальная глубина рекурсии при прохождении узла «выражение» [закрыто]Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 RecursionError: превышена максимальная глубина рекурсии при прохождении узла «выражение» [закрыто]

Сообщение Anonymous »


When I used the auto py to exe module to package Python files into the exe file format, I encountered an error and the program did not contain recursive statements. Why does an error occur: RecursionError: maximum recurrence depth exceeded while trading 'expr' node

Looking forward to successful execution

''''

import os import pandas as pd from sqlalchemy import create_engine from sqlalchemy.exc import SQLAlchemyError import logging import PySimpleGUI as sg logging.basicConfig(filename='输出日志.log', level=logging.INFO, format='%(asctime)s - %(levelname)s: %(message)s') sg.theme('LightGrey1') # 获取当前文件所在目录 current_directory = os.path.dirname(__file__) layout = [ [sg.Text('质检数据导入', font=('楷体', 20), text_color='#333')], [sg.Text('账户名:', size=(15, 1), text_color='#333'), sg.InputText(key='username', size=(20, 1))], [sg.Text('密码:', size=(15, 1), text_color='#333'), sg.InputText(key='password', password_char='*', size=(20, 1))], [sg.Button('登录', size=(20, 1), button_color=('#fff', '#4CAF50')), sg.Button('取消', size=(20, 1), button_color=('#fff', '#f44336'))] ] window = sg.Window('登录', layout, background_color='#fff', element_justification='center') event, values = window.read() if event == '登录': login_username = values['username'] login_password = values['password'] else: print('用户取消登录,程序退出...') sg.popup_error('用户取消登录,程序退出...', title='失败') window.close() exit() window.close() correct_user = 'admin' correct_password = 'admin' if login_username == correct_user and login_password == correct_password: try: # 构建Excel文件路径 excel_file_path = os.path.join(current_directory, "数据导入.xlsx") wr = pd.ExcelWriter(excel_file_path, engine='openpyxl', mode='a') total = pd.read_excel(wr, sheet_name='质检数据') # 构建数据库连接字符串 database_user = 'sss' database_password = 'xxx' database_host = '168.173.18.35' database_port = '3306' database_name = 'zyzy' engine = create_engine(f'mysql+mysqlconnector://{database_user}:{database_password}@{database_host}:{database_port}/{database_name}') # Selecting specific fields/columns for duplicate check selected_fields = ['work_group', 'stage_name', 'employee_name', 'consult_account', 'product_no', 'deduction_point', 'inspect_item', 'inspect_remarks'] # Add other fields as needed selected_total = total[selected_fields] # Check for duplicates existing_records = pd.read_sql("SELECT work_group, stage_name,employee_name,consult_account,product_no,deduction_point,inspect_item,inspect_remarks FROM ods_excel_inspection_data", engine) duplicates = selected_total.merge(existing_records, how='inner') if not duplicates.empty: logging.warning('发现重复记录,导入操作已取消') sg.popup_error('发现重复记录,导入操作已取消', title='失败', button_color=('#fff', '#f44336')) exit() # Use to_sql method to import DataFrame into MySQL database total.to_sql('ods_excel_inspection_data', con=engine, index=False, if_exists='append') logging.info('导入成功') # Clear data from Excel file, leaving only the header wr.close() wr = pd.ExcelWriter(excel_file_path, engine='openpyxl', mode='w') total.iloc[0:0].to_excel(wr, sheet_name='质检数据', index=False, header=True) wr._save() logging.info('清空Excel文件数据成功') # Write processed data back to a new Excel file new_excel_file_path = os.path.join(current_directory, "转换数据.xlsx") new_excel_file = pd.ExcelWriter(new_excel_file_path, engine='openpyxl') total.to_excel(new_excel_file, sheet_name='质检数据', index=False) new_excel_file._save() logging.info('导出到新Excel文件成功') # Display success popup sg.popup('导入成功', title='成功', button_color=('#fff', '#4CAF50')) except SQLAlchemyError as e: logging.error(f'导入失败: {e}') # Display error popup sg.popup_error(f'导入失败: {e}', title='失败', button_color=('#fff', '#f44336')) finally: # Regardless of success or failure, close the database connection engine.dispose() else: print('用户名或密码错误,程序退出...') sg.popup_error('用户名或密码错误,程序退出...', title='失败', button_color=('#fff', '#f44336')) ''''


Источник: https://stackoverflow.com/questions/781 ... -expr-node
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»