Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
我得到的值是123456,我想在快速编程中将此值转换为1,23,456。我怎样才能做到这一点 ?

最佳答案

这是印度风格的数字格式,其中100,000
(写为1,00,000)是一个"lakh"

Currency Formatter for different Locale in iOS转换和简化Objective-C代码可以得到:

let formatter = NSNumberFormatter()
formatter.numberStyle = .DecimalStyle
formatter.locale = NSLocale(localeIdentifier: "en_IN") // English (India) locale

let number = 12345678
let string = formatter.stringFromNumber(number)!
println(string) // 1,23,45,678




Swift 3更新:

let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.locale = Locale(identifier: "en_IN") // English (India) locale

let number = 12345678
let string = formatter.string(for: number)!
print(string) // 1,23,45,678

关于ios - Int NSFormatter,可快速将123456更改为1,23,456,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49249322/

10-12 04:32