python format string thousand separator with spaces January 22, 2023 by Tarik Here is bad but simple solution if you don’t want to mess with locale: '{:,}'.format(1234567890.001).replace(',', ' ')