admin管理员组文章数量:1605045
python 开发金山打字通辅助脚本
- 环境
- 开发步骤
- 代码
环境
这个脚本主要是靠python的pyautogui库实现,使用五笔输入法进行输入。
请先下载安装搜狗五笔或者别的五笔输入法,搜狗输入法下载
from xml.dom.minidom import parse
from lxml import etree
import requests, pyautogui, json, os, time, string
开发步骤
通过研究金山打字通的文件,发现金山打字通的文章存储在xml文件内
文件内容:
1.搜索出金山打字通根目录下所有的xml文件
def get_files(path,rule):
all = []
# fpathe 表示当前正在访问的文件夹路径
# dirs 表示该文件夹下的子目录名list
# fs 表示该文件夹下的文件list
for fpathe, dirs, fs in os.walk(path): # os.walk获取所有的目录
for f in fs:
if f.endswith(rule): # 判断是否是".xml"结尾
all.append(str(fpathe).replace('\\', '/', 100) + r'/' + str(f))
return all
2.解析xml文件
py_text = []
file = r"D:\Program Files (x86)\Typeeasy\11.5\course\test\cn\1.xml" #xml 文件路径
DOMTree=parse(file) # 打开xml文件
booklist=DOMTree.documentElement #获取XML文档对象
courseInfo = booklist.getElementsByTagName('courseInfo') #查找courseInfo元素
if courseInfo:
content = booklist.getElementsByTagName('item') #查找item元素
for con in content:
py_text.append(con.getAttribute
版权声明:本文标题:python 开发金山打字通辅助脚本 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728473248a1159795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论