红星闪闪的M 2021-04-07 09:36 采纳率: 57.1%
浏览 37
已结题

帮忙看看语句哪里不对?

import os
from selenium import webdriver
from WechatPCAPI import WechatPCAPI
import time
from time import sleep
import xlwings as xw
import logging
from queue import Queue
logging.basicConfig(level=logging.INFO)
queue_recved_message = Queue()

def on_message(message):
    queue_recved_message.put(message)
def main():
    help(WechatPCAPI)
wx_inst = WechatPCAPI(on_message=on_message,log=logging)
wx_inst.start_wechat (block=True)
while not wx_inst.get_myself ():
    time.sleep (2)
    while True:
        msg=queue_recved_message.get()
        if msg.get("type")=="msg::single":
            data=msg.get('data')
            send_or_recv=data.get('send_or_recv')
            char_type=data.get("data_type")
            if send_or_recv=='发数据':
                messageinfo=data.get('msg')
                if messageinfo is not None:
                    wx_id=str(data.get('from_wxid'))
                break
            else:
                continue
def driver():
    profile = webdriver.FirefoxProfile ()
    profile.set_preference ('browser.download.dir', 'E:\\下载')
    profile.set_preference ('browser.download.folderList', 2)
    profile.set_preference ('browser.download.manager.showWhenStarting', False)
    profile.set_preference ('browser.helperApps.neverAsk.saveToDisk', 'application/x-excel')
    driver = webdriver.Firefox (firefox_profile=profile)
    driver.get ('http://report2.hualife.cc:8071/WebReport/ReportServer?op=fs')
    driver.maximize_window ()
    time.sleep (3)
    driver.find_element_by_xpath ("/html/body/div[2]/div[3]/div[2]/input").send_keys ("******")
    driver.find_element_by_xpath ("/html/body/div[2]/div[3]/div[3]/input").send_keys ("*******")
    driver.find_element_by_id ("fs-login-btn").click ()
    time.sleep (3)
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[1]/div[1]/div/ul/li[1]/a/span[2]").click ()
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[1]/div[1]/div/ul/li[1]/ul/li[1]/a/span").click ()
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[1]/div[1]/div/ul/li/ul/li[1]/ul/li[1]/a/span").click ()
    time.sleep (2)
    driver.switch_to.frame (driver.find_element_by_xpath ("/html/body/div[1]/div[2]/div/div[4]/iframe[2]"))
    time.sleep (4)
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[2]/div/div[12]/div[2]/div").click ()
    driver.find_element_by_xpath ("/html/body/div[3]/div[3]/div[2]").click ()
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[2]/div/div[19]/div[2]/div").click ()
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[2]/div/div[19]/div[2]/div").click ()
    driver.find_element_by_xpath ("/html/body/div[3]/div[5]/table[1]/tbody/tr[1]/td[6]").click ()
    driver.find_element_by_xpath ("/html/body/div[1]/div[1]/div[2]/div/div[16]/div/div/em/button").click ()
    time.sleep (7)
    driver.find_element_by_xpath ("/html/body/div[2]/table/tbody/tr/td[11]/div/div/div/em/button").click ()
    time.sleep (20)
    driver.close ()

def read_exccel():
    app = xw.App (visible=True, add_book=False)
    wb = app.books.open (r'E:/䐁蕳/营销渠道保单清单.xlsx')
    time.sleep (2)
    sht = wb.sheets['sheet1']
    sht.api.Rows (2).Delete ()
    sht.api.Rows (1).Delete ()
    sht.api.Columns (1).Delete ()
    time.sleep (2)
    exist_list = ["正常有效", "标体通过", "承保", "人工核保", "新增险种", "自核通过"]
    rows = sht.api.UsedRange.Rows.count
    cols = sht.api.UsedRange.columns.count
    rng = sht[0, :cols]

    for cell in rng:
        if cell.value == '保单状态':
            print (cell.address)
            a = cell.address
    a_range = sht.range ("AO2:AO" + str (rows))

    cell_list = []
    for cell in a_range:
        cell_list.append (cell)
    cell_list.reverse ()

    print ("   开始调整行和列……")
    for cell in cell_list:
        if cell.value is not None:
            find_flag = 0
            for exist_value in exist_list:
                if cell.value.find (exist_value) != -1:
                    find_flag = 1
                    break
                else:
                    continue
            if find_flag == 0:
                cell_to_del = cell.address
                sht.range (cell_to_del).api.EntireRow.Delete ()
    time.sleep (2)
    driver.close ()
    wb1 = app.books.open (r"C:/Users/Administrator/Desktop/KPI2.xlsm")
    time.sleep (8)
    sht1 = wb1.sheets['更新业绩表']
    sht1.range ("a1").expand ("table").clear_contents ()
    wb.sheets["sheet1"].range ("a1").expand ("table").api.Copy (sht1.range ('a1').api)
    wb.close ()
    os.remove (r'E:/䐁蕳/营销渠道保单清单.xlsx')
    app.calculate ()
    time.sleep (10)
    wb1.api.Application.Run ("all")
if __name__ == '__main__':
    main()
  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-09-07 17:10
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月28日
  • 已采纳回答 9月20日

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: