Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Python String Question
-
Hello,
I Have a question about Python String formating.
This is my String:csvFile__ProjectID = 83498246 rexelCSV = '%sr.csv' % (csvFile__ProjectID)
Is it possible to do like this:
file Exempel:
83498246r1.csv
83498246r10.csv
83498246r17.csv
csvFile__ProjectID = 83498246 rexelCSV = '%sr?.csv' % (csvFile__ProjectID)
The
?
is for any KeyI hope you understand what I want 😂
-
csvFile__ProjectID = 83498246 for i in range(20): print(f"{csvFile__ProjectID}r{i}.csv")
-
@ccc
Okay, I thought there was a nicer solution like placeholders or something.but thank you for your fixed answer 👍
-
The alternatives with relative speed are at https://www.scivision.dev/python-f-string-speed
-
csvFile__ProjectID = 83498246 for i in range(20): print(f"{csvFile__ProjectID}r{i:02}.csv")
So you don't hate yourself later, when you have wwritten folders and folders of files that won't sort properly.
-
@JonB
Thank you 👍 -
This post is deleted!