[Tutor] way of dictating leading zeros
Patrick
optomatic at rogers.com
Mon Mar 16 03:47:49 CET 2009
Hi Everyone
I am trying to write a program that creates a bunch of svg files and
then edits their values. I am then encoding them into a video. It's not
encoding right because my filenames are wrong. They have to have a
sequence. Right now they are 1.svg, 2.svg, 3.svg etc but they should be
001.svg, 002.svg, 003.svg. At the moment I think 12.svg is ending up
before 2.svg because it starts with 1.
Is there an easy way to dictate how many digits a number will occupy
that also allows for leading zeros?
Below is a sample of my code if it helps:
Thanks in advance-Patrick
def thingcreate():
thingfile = raw_input("Enter full pathname of your template: ")
thingseconds = raw_input("Enter how many seconds your film will be: ")
thingseconds =int(thingseconds)
thingframes = raw_input("Enter how many frames per second your film
will be: ")
thingframes =int(thingframes)
thingnumber = thingframes * thingseconds
f = open(thingfile, 'r')
thingread = f.read()
for i in range(thingnumber):
i = str(i)
file =open(i+".svg", 'w')
file.write(thingread)
file.close()
More information about the Tutor
mailing list