英语听写小软件

为提高英语单词记忆效果,利用Python及pyttsx3库开发了一款听写软件,通过随机抽取单词进行听写和翻译练习,适用于个人英语学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

因为自己英语不太行,然后单词平常记忆老是忘记,但是觉得如果有听写的话,记忆力会大大提高,所以借用python写了一个小软件。

用到了python中的一个pyttsx3发音工具包。

实现过程很容易,下面就直接把放上来。

# -*- coding: utf-8 -*-
"""
Created on Tue Sep 25 18:11:09 2018

@author: C_hao
"""

import pyttsx3
import random
print("开始进行拼写,输入结束即停止程序")
print("拼写英文,请输入1")
print("拼写中文,请输入2")
temp=input("请输入选项:")
if temp=='1':
    wd=0
    trl=1
else:
    wd=1
    trl=0
f = open(r"english.txt",'r')        
line = f.readline()              
engine = pyttsx3.init()
content=[]
while line:
    line=str(line).strip()
    content.append(line.split('-'))
    line = f.readline()
f.close() 

while True:
    x=random.randint(0,len(content)-1)
    engine.say(content[x][wd])
    engine.runAndWait()
    word=input("请拼写:")
    word=word.strip()
    if content[x][wd]==word:
        print("拼写正确")
    elif word=="结束":
        break
    else:
        print("拼写错误")    
    translate=input("请翻译:")
    translate=translate.strip()
    if content[x][trl]==translate:
        print("翻译正确")
    elif translate=="结束":
        break
    else:
         print("翻译错误")


这是english.txt中里面文本的内容:

management-管理
hello-你好

 

下面写个.bat程序即可每次点击就可以运行。

python dication.py

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值