python 答题辅助_答题辅助python代码实现
本文实例为大家分享了答题辅助python具体代码,供大家参考,具体内容如下
from screenshot import pull_screenshot
import time, urllib.request
try:
import Image
except ImportError:
from PIL import Image, ImageDraw
import pytesseract
# 屏幕顶端到问题的距离/屏幕高度,随分辨率变化(默认1920*1080)
top_off_c = 0.15
# 问题高度
que_h = 300
# 答案高度
ans_h = 170
# 左右偏移量
l_r_off = 40
def check(question, ans):
q_url = "http://www.baidu.com/s?word=" + urllib.parse.quote(question)
resp = urllib.request.urlopen(q_url)
print(resp.read().decode("utf-8"))
def draw():
img = Image.open('autojump.png')
w, h = img.size
draw = ImageDraw.Draw(img)
draw.line((40, h * 0.15, w - 40, h * 0.15), fill="red")
draw.line((40, h * 0.15 + 300, w - 40, h * 0.15 + 300), fill="red")
draw.line((40, h * 0.15 + 470, w * 0.7, h * 0.15 + 470), fill="red")
draw.line((40, h * 0.15 + 640, w * 0.7, h * 0.15 + 640), fill="red")
draw.line((40, h * 0.15 + 810, w * 0.7, h * 0.15 + 810), fill="red")
img.show()
def main():
while True:
print(">>>>>>")
pull_screenshot()
img = Image.open('autojump.png')
img = img.convert('L')
w, h = img.size
img_q = img.crop((l_r_off, h * top_off_c, w - l_r_off, h * top_off_c + que_h))
img_a = img.crop((l_r_off, h * top_off_c + que_h, w * 0.7, h * top_off_c + que_h + ans_h))
img_b = img.crop((l_r_off, h * top_off_c + que_h + ans_h, w * 0.7, h * top_off_c + que_h + ans_h * 2))
img_c = img.crop((l_r_off, h * top_off_c + que_h + ans_h * 2, w * 0.7, h * top_off_c + que_h + ans_h * 3))
question = pytesseract.image_to_string(img_q, lang='chi_sim')
ans_a = pytesseract.image_to_string(img_a, lang='chi_sim')
ans_b = pytesseract.image_to_string(img_b, lang='chi_sim')
ans_c = pytesseract.image_to_string(img_c, lang='chi_sim')
question = question.replace(" ", "").replace(".", "")
ans = ["1", "1", "1"]
ans[0] = ans_a.replace(" ", "").replace(".", "")
ans[1] = ans_b.replace(" ", "").replace(".", "")
ans[2] = ans_c.replace(" ", "").replace(".", "")
print(question.replace(" ", "").replace(".", ""))
print(ans)
check(question, ans)
# draw()
time.sleep(1)
if __name__ == '__main__':
main()
文字识别
sudo pip3 install pytesseract
sudo apt-get install tesseract-ocr
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持找一找教程网。
python 答题辅助_答题辅助python代码实现相关推荐
- python 多核并行计算_手把手 | 嫌Python太慢?并行运算Process Pools三行代码给你4倍提速!...
大数据文摘作品,转载要求见文末 作者 | Adam Geitgey 编译 | 元元.Lisa.Saint.Aileen 原文链接 | https://medium.com/@ageitgey/quic ...
- python gui包_超酷 Python 程序包 ,一行代码搭建 GUI 界面
在 Github 闲逛时,发现一款 牛 X 的 Python 包,今天在这里介绍给大家: 当用 Python 搭建 GUI 界面时,首选 PyQt5 和 Tkinter,当然这两个包的功能强大的事实毋 ...
- csdn学院的python培训怎么样_这段 Python 代码让程序员赚 300W,公司已确认!网友:神操作...
Python到底还能给人多少惊喜? 笔者最近看到了这两天关于Python最热门的话题,关于<地产大佬潘石屹学Python的原因>,结果被这个回答惊到了: 来源:知乎 https://www ...
- python非法的_在下列Python语句中非法的是________。
[判断题]Directions: The following exercises will test your understanding of the concepts of critical th ...
- 文科生自学python要多久_怎么自学python,大概要多久?
都让开!本人文科生,自学Python 2年半,作为一个曾经完全0基础,啥都不懂纯靠自学学会python的文科生,有一些不成熟的小建议可以分享一下. 首先不要觉着编程难,只要你认识26个英文字母,有一点 ...
- python优化网站_[练习] 用PYTHON来优化网站中的图片
我到公司以来,第一次加班,哇,加一晚上加一上午,现在还没下班的迹象,555,困. 对于网站中的一些关键的页面,多重缓存.静态化.程序代码优化--之外,为了提高用户打开页面的速度,图片是必须要优化的. ...
- python新手难点_汇总初学python时的28个操作难点(新手必看篇)
前言: 今天带来的内容是针对刚学习Python的程序员,内容详细的介绍了Python操作难点总结,换句话说就是一些基础的小知识,为了更效率的运用Python,喜欢的话直接收藏留着慢慢看就行了. 内容一 ...
- python递归函数例题_递归案例python
广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! 而对应的中文翻译 "递归" 却表达了两个意思:"递 ...
- python列表拆包_详解python 拆包可迭代数据如tuple, list
详解python 拆包可迭代数据如tuple, list 拆包是指将一个结构中的数据拆分为多个单独变量中. 以元组为例: >>> a = ('windows', 10, 25.1, ...
- python学习图解_轻松学Python 3 零基础彩色图解、专业入门
哈啰,Python Python无疑是当今最值得学习的程式语言,因为它不仅语法简单,而且功能强大,还可以在Windows.Mac OS和Linux等所有平台上执行.再加上拥有将近十万个各式各样的套件, ...
最新文章
- PIE SDK热力图
- ES6-let const
- Linux入门——文件管理
- OpenCV-Python 中文教程(搬运)目录
- java先进先出 循环队列,JavaScript队列、优先队列与循环队列
- AI超人赛车手狂虐人类登Nature封面!1000台PS4训练,「苏菲」极限超车独霸赛道...
- 一文玩转 EhCache 缓存框架!
- 计算机视觉论文-2021-06-21
- 远程服务器返回错误 (411) 所需的长度。
- JxBrowser 7 Crack 申请试用教程
- 插头dp ——从入门到跳楼
- for循环及判断语句的20个经典习题
- BSW系列:CFAR算法解析
- Android/Linux Thermal Governor之IPA分析与使用
- 美图秀秀api实现图片的裁剪及美化
- 阿里玄难:面向不确定性的软件设计几点思考
- 2021十大手表品牌TOP排行榜
- PHPSTUDY端口被占用解决方法
- 在计算机科学中 算法这个术语是指什么,algorithm
- bugku 游戏过关