Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
python coma valores separados por miles sin ceros finales

Estoy tratando de separar por comas la cantidad flotante por miles. Puedo hacerlo usando la función locale.format(). Pero el resultado esperado no está considerando los puntos decimales.

 import locale locale.setlocale(locale.LC_ALL, 'en_US') amount = locale.format('%d', 10025.87, True) amount '10,025'

Mi resultado esperado debería ser 10.025,87, manteniendo los valores finales. Por favor, hágamelo saber si algo de este tipo es posible

 Value: 1067.00 Output: 1,067 Value: 1200450 Output: 1,200,450 Value: 1340.9 Output: 1,340.9
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Qué tal esto:

 import locale locale.setlocale(locale.LC_ALL, 'en_US') # strip any potential trailing zeros because %f is used. amount = locale.format('%f', 10025.87, True).rstrip('0').rstrip('.') amount # '10,025.87'
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!