Jacklovely

导航

 

说明:

1. 本来是要写个脚本生成点拨rtf给讲师朗读的,不过实在是安装不上pywin32这个模块,虽然下载下来了whl文件,pip install 也能安装,但是导入pywin32、win32com这些都报错,只有导入pywin不报错,但我又不知道这个pywin是不是操作word那个,查了下资料,又想起了当年查这个api文档的痛苦,恰好看到一篇文章http://blog.csdn.net/ccbird88/article/details/6193769里面的一句话:注意: Python来开发Word速度实在是太慢,建议用C#,顿时释然了。

2. 或许python暂时只适合我用来写爬虫,先告一段落吧!

 1 import os
 2 import shutil
 3 import pywin
 4 
 5 
 6 oriPath = r"OriFolder"
 7 desPath = r"DesFolder"
 8 rtfBooks = []
 9 bookNames = os.listdir(oriPath)
10 # print(os.getcwd())
11 def createRTF():
12     os.chdir(desPath)
13     if not os.path.exists(bookNames[0]):
14         os.mkdir(bookNames[0])
15     else: 
16         pass
17     os.chdir(bookNames[0])
18     with open("233.rtf","w") as f:
19         f.write("123")
20 
21 # for paths,folders,filenames in os.walk(jbPath):
22 #     for filename in filenames:
23 #         #print(paths)
24 #         rtfBooks.append(os.path.join(paths,filename))
25 # for rtfBook in rtfBooks:
26 #     print(rtfBook)

 

posted on 2017-03-13 19:17  Jacklovely  阅读(320)  评论(0编辑  收藏  举报