在网上找到了一本非常喜欢的电子书,但是它是繁体字。在网上找了很多转换工具不是收费就是转换后格式出现问题,后面又找到了一段python代码,使用起来非常简单,而且格式不会出现问题,非常好用!
import opencc
import os
import zipfile
import shutil
def test_convert():
"""
s2t.json Simplified Chinese to Traditional Chinese 簡體到繁體
t2s.json Traditional Chinese to Simplified Chinese 繁體到簡體
"""
converter = opencc.OpenCC('s2t')
print(converter.convert('汉字acb')) # 漢字
converter = opencc.OpenCC('t2s')
print(converter.convert('漢字123')) # 漢字
def unzip_dir(zipfilename, unzipdirname):
"""解压zip文件"""
fullzipfilename = os.path.abspath(zipfilename)
fullunzipdirname = os.path.abspath(unzipdirname)
print("Start to unzip file %s to folder %s ..." % (zipfilename, unzipdirname))
# Check input ...
if not os.path.exists(fullzipfilename):
print("Dir/File %s is not exist, Press any key to quit..." % fullzipfilename)
inputStr = input()
return
if not os.path.exists(fullunzipdirname):
os.mkdir(fullunzipdirname)
else
389



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



