///字符串转双精度后去除小数点00 static func convertStringToString(_ str: String) -> String? { if let doubleValue = Double(str) { let numberFormatter = NumberFormatter() numberFormatter.minimumFractionDigits = 0 numberFormatter.maximumFractionDigits = doubleValue.truncatingRemainder(dividingBy: 1) == 0 ? 0 : 2 return numberFormatter.string(from: NSNumber(value: doubleValue)) } return nil }