Skip to content

Commit d89d991

Browse files
committed
新增 简体转繁体python脚本
1 parent b6de076 commit d89d991

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

convert.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
#-*- coding:utf-8 -*-
3+
4+
"""
5+
简体转繁体
6+
"""
7+
8+
import os
9+
import sys
10+
import json
11+
from opencc import OpenCC
12+
13+
source_file = "/Users/hx/DCloud/hbuilderx-extension-docs/zh-hant/Tutorial/Other/themes_param.md"
14+
15+
# s2t 简体 -> 繁体
16+
# s2tw 简体 -> 台湾繁体
17+
# s2hk 简体 -> 香港繁体
18+
19+
cc = OpenCC('s2t')
20+
# cc.convert(to_convert)
21+
22+
with open(source_file, "r") as f:
23+
source_data = f.read()
24+
25+
last_result = cc.convert(source_data)
26+
27+
with open(source_file, "w") as f:
28+
f.write(last_result)

0 commit comments

Comments
 (0)