Life is Short, I Use Python – A Wubi Query Program in Ten Lines of Code

Recently, I have been learning Wubi typing. On one hand, it is to make up for the regret of not learning it well thirty years ago (when I was young, I only memorized the Wubi mnemonic). On the other hand, as I age, my physical strength is not what it used to be, and typing has become difficult, while Wubi requires fewer keystrokes. Although language input methods are now widely used, writing articles still requires inspiration to come word by word. The first step is to obtain a character database.

Life is Short, I Use Python - A Wubi Query Program in Ten Lines of Code

Using awk, I split it into two txt files, with the split content as follows:

Life is Short, I Use Python - A Wubi Query Program in Ten Lines of Code

Based on the above content, I wrote the code in Python.

Life is Short, I Use Python - A Wubi Query Program in Ten Lines of Code

Run the code for testing.

Life is Short, I Use Python - A Wubi Query Program in Ten Lines of Code

Upon running, we find that by inputting a Chinese character, we can obtain the corresponding Wubi code. There may be a few Chinese characters that cannot find a corresponding [a-z], and we just need to append them in the two txt files above.

Leave a Comment