python答题系统的代码_答题辅助python代码实现
本⽂实例为⼤家分享了答题辅助python具体代码,供⼤家参考,具体内容如下
from screenshot import pull_screenshot
import time, quest
try:
import Image
except ImportError:
from PIL import Image, ImageDraw
import pytesseract
# 屏幕顶端到问题的距离/屏幕⾼度,随分辨率变化(默认1920*1080)
top_off_c = 0.15
python新手代码画图# 问题⾼度
que_h = 300
# 答案⾼度
ans_h = 170
# 左右偏移量
l_r_off = 40
def check(question, ans):
q_url = "www.baidu/s?word=" + urllib.parse.quote(question)
resp = quest.urlopen(q_url)
ad().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 = vert('L')
w, h = img.size
img_q = p((l_r_off, h * top_off_c, w - l_r_off, h * top_off_c + que_h))
img_a = p((l_r_off, h * top_off_c + que_h, w * 0.7, h * top_off_c + que_h + ans_h))
img_b = p((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 = p((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 = place(" ", "").replace(".", "")
ans = ["1", "1", "1"]
ans[0] = place(" ", "").replace(".", "")
ans[1] = place(" ", "").replace(".", "")
ans[2] = place(" ", "").replace(".", "")
place(" ", "").replace(".", ""))
print(ans)
check(question, ans)
# draw()
time.sleep(1)
if __name__ == '__main__':
main()
⽂字识别
sudo pip3 install pytesseract
sudo apt-get install tesseract-ocr
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。