NSString 位数不足补0 %0nd ,n是多少位。0表示补0 如果是%nd,就是不满n位,自动补充空格。 NSString * testStr; int f = 12; testStr = [NSString stringWithFormat:@”%03d”,f]; NSLog(@”%@”,testStr);