Chinese punctuation to English punctuation

Python中:中文标点转换成英文标点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# In Python3, use str.maketrans instead
table = {ord(f):ord(t) for f,t in zip(
u',。!?【】()%#@&1234567890',
u',.!?[]()%#@&1234567890')}
t = u'中国,中文,标点符号!你好?12345@#【】+=-()'
t2 = t.translate(table)
'''
>>> print t2
中国,中文,标点符号!你好?12345@#[]+=-()
'''
作者:灵剑
链接:https://www.zhihu.com/question/37720196/answer/115870233
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

链接