无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

傻瓜讀書軟件在升級(III)

2020-03-04 20:43 作者:一心想當網(wǎng)紅的李老師  | 我要投稿

這次案件只有一個了。

再大神的指導(dǎo)下,成功分析了文件類型,然后選擇了合適的處理方式。目前可以處理txt和word文件。感覺又有了提高。

代碼如下:(python3.7版本)

#! /usr/bin/env python

# -*- coding: utf-8 -*-

import importlib,sys

importlib.reload(sys)


import tkinter

from tkinter.filedialog import askopenfilename

from docx import Document

from docx.shared import Inches

import pyttsx3

import os


l=[]

def openfile():

? ? file_path=askopenfilename()

? ? if os.path.splitext(str(file_path))[1]=='.txt': ? ?###利用os模塊的功能,成功分解文件的后綴

? ? ? ? f=open(file_path,encoding='utf-8')

? ? ? ? fread=f.read()

? ? ? ? f=str(fread)

? ? ? ? engine=pyttsx3.init()

? ? ? ? engine.say(f)

? ? ? ? engine.runAndWait()

? ? elif os.path.splitext(str(file_path))[1]=='.docx':

? ? ? ? f=Document(file_path)

? ? ? ? for para in f.paragraphs:

? ? ? ? ? ? l.append(para.text)

? ? ? ? engine=pyttsx3.init()

? ? ? ? engine.say(str(l))

? ? ? ? engine.runAndWait()



top=tkinter.Tk()

Button1=tkinter.Button(top, text ="選擇文件", command = openfile)

Button1.pack()

top.mainloop()

雖然不是非?,F(xiàn)代化,但是更加進步了一下。后續(xù)繼續(xù)升級改造。

傻瓜讀書軟件在升級(III)的評論 (共 條)

分享到微博請遵守國家法律
莒南县| 津南区| 江北区| 昌江| 尼木县| 水城县| 珲春市| 宜宾市| 花莲县| 英吉沙县| 清水河县| 红安县| 富平县| 潜山县| 仁化县| 纳雍县| 小金县| 沾化县| 武功县| 龙海市| 于都县| 基隆市| 陈巴尔虎旗| 柏乡县| 繁峙县| 德昌县| 饶阳县| 和田县| 攀枝花市| 长宁县| 青阳县| 阜城县| 靖西县| 玉林市| 合川市| 孟连| 日土县| 保德县| 靖江市| 东乡族自治县| 田阳县|