简体   繁体   English

将 str 转换为 int,反之亦然

[英]converting str to int and vice versa

I have a need to convert a string to an int and back after doing some processing.我需要在进行一些处理后将字符串转换为 int 并返回。 And the string has to be in words like below:并且字符串必须是如下的词:

45 - forty five 45 - 四十五
99 - ninety nine 99 - 九十九

I searched everywhere for a hint but couldn't find any.我到处寻找提示,但找不到任何提示。 I know the obvious switch-case logic but I am curious if theres a more intelligent way doing it with less lines of code.我知道明显的 switch-case 逻辑,但我很好奇是否有一种更智能的方法可以用更少的代码行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM