Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert python Chinese capitals to Arabic numerals

Shulou Source: shulou.com Published: 2022-06-02 12:58:07 10月04日 Update

This article mainly explains "python Chinese capitalization how to convert Arabic numerals," interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "python Chinese capitalization how to convert Arabic numerals"!

The integer part is mainly searched by regular expressions, multiplying the number of the corresponding item by the corresponding item in the unit list and summing it up. The fractional part is also the same way. However, since there may be cases where there are only angles, regular expressions are not easy to handle, and angles and points are not involved in many cases here, so we separate them.

1. initialization parameters

2. Handling integer parts

I. Search by template using regular expressions (from megabit to bit, null if no corresponding item)

II. Mapping is performed according to the mapping table and then combined into a numerical list

III. Multiply the number list by the corresponding index item of the number unit list and sum

3. Handling fractional parts

I. Length is 4: N angle N minutes, get the number corresponding to angle sum minutes, multiply and sum with unit after mapping

II. Length is 3: zero N minutes, get the number corresponding to the minute, multiply with the unit after mapping

III. Length is 2, N angle, get the number corresponding to the angle, multiply with the unit after mapping

4. data mapping

Same as the mapping method mentioned earlier, just swap numbers with Chinese characters, here there is a processing of strings, if it is in the form of zero N, replace the string with N, if it is an empty string, perform mapping according to zero

5. data check

Judge the rationality of data

At this point, I believe that everyone has a deeper understanding of "python Chinese capitalization how to convert Arabic numerals," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Number unit processing partial uppercase Arabic numeral Allah Chinese data regular expression length content character string decimal case integer method I. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Linux Redmi MariaDB macOS