Python Forum
Adding string after every 3rd charater [SOLVED]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding string after every 3rd charater [SOLVED]
#3
(Jul-10-2022, 03:15 PM)AlphaInc Wrote: If (which I think will be the case) this is too complex and there is a far easier method, please let me know :)
Congratulations, well done. But indeed there is an easier method: use an f-string and mark the type as "n" (number). But then you need to set the locale of your environment. (Not sure if this works also with Windows.)
PyDev console: starting.
Python 3.9.5 (default, Nov 23 2021, 15:27:38) 
[GCC 9.3.0] on linux

import locale
locale.setlocale(locale.LC_ALL, '')  # Get the locale from your OS
'nl_NL.UTF-8'
aa = 1234567890
print(f"{aa:n}")
1.234.567.890
Reply


Messages In This Thread
RE: Adding string after every 3rd charater [SOLVED] - by ibreeden - Jul-11-2022, 09:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into </>? Winfried 0 1,507 Sep-03-2022, 11:21 PM
Last Post: Winfried
  [SOLVED] [BeautifulSoup] Turn select() into comma-separated string? Winfried 0 1,112 Aug-19-2022, 08:07 PM
Last Post: Winfried
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 2,199 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  Replace String in multiple text-files [SOLVED] AlphaInc 5 8,089 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  Replace String with increasing numer [SOLVED] AlphaInc 13 5,002 Aug-07-2021, 08:16 AM
Last Post: perfringo
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 2,265 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B
  Adding an ascending number [SOLVED] AlphaInc 3 2,234 Jul-11-2021, 10:13 AM
Last Post: perfringo
  reading lines from a string [Solved] ebolisa 14 6,352 Mar-28-2021, 08:16 PM
Last Post: perfringo
  Adding markers to Folium map only adding last element. tantony 0 2,120 Oct-16-2019, 03:28 PM
Last Post: tantony
  adding a string and an int ninjarunner2005 3 2,328 Dec-10-2018, 04:54 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020