我在轨道上的红宝石中有一个变量,其中包含此值 8,375 TND
_result = _orig_account.formatted_balance(_currency)
我想如果可以消除 TND ,然后将其余的乘以1000 ,以便得到 8375
可以帮我解决这个问题
我尝试使用此代码:
I try with : _tes = _orig_account.formatted_balance().tr(',', '.').to_f
_te = _tes * 1000
我的结果是: 8375.0
但正如我所说,我希望juste 8375
答案 0 :(得分:0)
更新:只需使用此'8,375 TND'.tr(',', '').to_i
答案 1 :(得分:0)
这是一个简单的操作:
'8,375 TND'.tr(',', '.').to_f
=> 8.375
乘以1000。