
批處理如何把中文數字轉換成阿拉伯數字自己寫的,誰能幫我簡化一下?感覺用4個set和call set部分太重復了。而且這個只能處理一千以下的。要能處理很大的數,該怎么改進。提提意見啊1.txt的內容隨便寫幾個:一百零五一百二十九十八五
nclick="copycode($('code0'));">復制代碼
- @echo off&setlocal enabledelayedexpansion
- set n=0
- for %%i in (零 一 二 三 四 五 六 七 八 九 十) do (
- set %%i=!n!
- set /a n+=1
- set /a n=!n! %% 10
- )
- for /f %%a in (1.txt) do (
- set s=%%a
- set s1=!s:~0,1!
- set s2=!s:~1,1!
- set s3=!s:~2,1!
- set s4=!s:~3,1!
- call set x1=%%!s1!%%
- call set x2=%%!s2!%%
- call set x3=%%!s3!%%
- call set x4=%%!s4!%%
- if !s3!== set x3=
- if !s2!==百 (set x=!x1!!x3!!x4!) else (set x=!x1!!x3!)
- echo !x!
- )
- pause

