0
点赞
收藏
分享

微信扫一扫

用python实现个人所得税批量申报,使用只需要修改部分数据。

天蓝Sea 2022-04-08 阅读 69
python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pyautogui
import time
import pyperclip
import openpyxl
import ctypes
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 6)

wb = openpyxl.load_workbook('C:/111.xlsx')
print(type(wb))  # 结果: <class 'openpyxl.workbook.workbook.Workbook'>形式
# 获取所有表的表名
sheets_names = wb.sheetnames
print(sheets_names)  # 结果: ['表1', '表2']
# 获取活动表对应的表对象(表对象就是Worksheet类的对象)
active_sheet = wb.active
print(active_sheet)  # 结果:<Worksheet "表1">
# 根据表名获取工作簿中指定的表
sheet2 = wb['Sheet2']
print(sheet2)  # 结果:<Worksheet "表2">
# 根据表对象获取表的名字
sheet_name1 = active_sheet.title
sheet_name2 = sheet2.title
print(sheet_name1, sheet_name2)  # 结果:表1 表2
# 获取活跃表对象
sheet = wb.active
time.sleep(10)  # 休眠10秒
for i in range(1,10,1):
    print(i)
    a1 = sheet['A'+str(i)]  # A1 表示A列中的第一行,这儿的列号采用的是从A开始的
    print(a1)  # 获取单元格中的内容
    content = a1.value
    print(content)  # 结果是: Rank
    pyperclip.copy(content)
    pyperclip.paste()
    time.sleep(1)  # 休眠1秒

    pyautogui.moveTo(x=1767, y=54, duration=0.1, tween=pyautogui.linear)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.mouseDown(x=837, y=361, button='left')
    time.sleep(2)
    pyautogui.mouseUp(x=1144, y=361, button='left', duration=5)
    time.sleep(2)
    pyautogui.hotkey('ctrl', 'v')  # 组合按键(Ctrl+V),粘贴功能,按下并松开'ctrl'和'v'按键
    time.sleep(2)

    b1 = sheet['B' + str(i)]
    print(b1)  # 获取单元格中的内容
    content = b1.value
    print(content)  # 结果是: Rank
    pyperclip.copy(content)
    pyperclip.paste()

    pyautogui.moveTo(x=999, y=373, duration=0.1, tween=pyautogui.linear)
    time.sleep(1)
    pyautogui.click()
    time.sleep(3)

    pyautogui.moveTo(x=1347, y=516, duration=0.1, tween=pyautogui.linear)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=853, y=564, duration=0.1, tween=pyautogui.linear)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.hotkey('ctrl', 'v')  # 组合按键(Ctrl+V),粘贴功能,按下并松开'ctrl'和'v'按键
    time.sleep(1)

    pyautogui.moveTo(x=1165, y=763, duration=0.1, tween=pyautogui.linear)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=1002, y=730, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(7)
    pyautogui.moveTo(x=1332, y=270, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=88, y=230, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=1747, y=284, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=960, y=630, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=921, y=596, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=724, y=486, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(1)
    pyautogui.moveTo(x=934, y=639, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(2)
    pyautogui.moveTo(x=1172, y=669, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(2)

    pyautogui.moveTo(x=252, y=191, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(2)
    pyautogui.moveTo(x=828, y=148, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(26)
    pyautogui.moveTo(x=1673, y=151, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(2)

    pyautogui.moveTo(x=1845, y=250, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(26)
    pyautogui.moveTo(x=915, y=575, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(3)
    pyautogui.moveTo(x=969, y=596, duration=0.1, tween=pyautogui.linear)
    time.sleep(0.5)
    pyautogui.click()
    time.sleep(2)

举报

相关推荐

0 条评论