数字前面补零

前端:

function PrefixInteger(num) {
    return (num / Math.pow(10, 2)).toFixed(2).substr(2);
}

C#后端:

string str='23';
str.PadLeft(4, '0'); //结果为为 '0023'
str.PadLeft(4, ' ') //补为空格  '  23'

猜你喜欢

转载自blog.csdn.net/Bambi12/article/details/82964790
今日推荐