def upload_file(file_path): ‘‘‘ :param file_path:上传文件的路径 :return: ‘‘‘ dialog = win32gui.FindWindow("#32770", "打开") comboxex32 = win32gui.FindWindowEx(dialog, 0, "ComboBoxEx32", None) combox = win32gui.FindWindowEx(comboxex32, 0, "ComboBox", None) edit = win32gui.FindWindowEx(combox, 0, "Edit", None) button = win32gui.FindWindowEx(dialog, 0, "Button", "打开(&0)") win32gui.SendMessage(edit, win32con.WM_SETTEXT, None, file_path) win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button) #【图片编辑】窗口-点击 选择图片 driver.find_element_by_css_selector(‘[class="btn-box"]>div‘).click() # 点击之后需要等待时间,可以根据情况调节等待时间 time.sleep(4) upload_file(r‘C:\Users\Vincent\1577799790527gcwz36gp.jpg‘)