用Python给宝宝写一个故事机
运行环境及其说明
-
Windows
-
Python3.6以上
-
可以朗读中文
需要安装的库
+ pypiwin32(用于朗读)
pip install pypiwin32
+ pandas(用于记录上一次阅读位置)
pip install pandas
+ linecache(读取文本文件的指定行)
pip install linecache
程序如下
"""
Create on Jan-30-2020
Author:CC
Evn:Python3.6
Only test on windows10
"""
import os, pandas as pd, linecache as lch, win32com.client
class cachefile:
"""
Read specific line of a txt
"""
def __init__(self, file_path):
self.max_line = len(lch.getlines(file_path))
self.file_path = file_pathdef getline(self, num):
&nb

本文介绍如何使用Python在Windows环境下为宝宝创建一个故事机,利用pypiwin32库进行语音朗读,Pandas记录阅读位置,linecache读取文本特定行。程序读取指定txt文件,逐行朗读,并更新进度记录。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



