如果您有这样的代码,则p将为"2.99":letprice=2.99letp=String(format:"%.2f",price)但是,如果您有这样的代码:letpriceNS:NSDecimalNumber=2.99letp2=String(format:"%.2f",priceNS)那么p2就是"0.00"。如何将NSDecimalNumber格式化为这样的字符串?(NSDecimalNumber是SKProduct中价格的存储方式) 最佳答案 您应该使用NumberFormatter格式化您的产品价格并使用您的产品区域设置: