Skip to main content
100%

[中文标点转英文] #string

✓ Published0🌍 Public
SShawn91
Last edited Jan 25, 2019
Created on Jan 21, 2019

This example demonstrates a Python utility that converts Chinese punctuation marks into their English equivalents in a given string. The function `punc_chinese2english` builds translation tables using the built-in `str.maketrans` method, mapping a set of characters such as full-width commas, periods, and quotation marks to standard ASCII punctuation. It applies this mapping via the string `translate` method, returning the converted text. The code explicitly lists the Chinese and English punctuation pairs, making the transformation rule clear and easy to modify.

AI-generated description

Similar vizzes