I have a script that creates a random string and I want to turn that in to a placeholder.
Here’s my script:
import random
def randstring(length=10):
valid_letters='abcdefghijklmnopqrstuvqxyz1234567890'
return ''.join((random.choice(valid_letters) for i in xrange(length)))
print randstring(15)
#prints something like "qkxfdqp5jockf6n"
I want to be able to turn the created value of “randstring(15)” into a conversion specifier such as %s or %d.
This should be simple but I can’t figure it out.
Thanks.
%sis not magic, and it doesn’t magically know what you want to substitute in. It’s a placeholder. You substitute your string into it the same way you would substitute any other string:There is no “turning” of anything “into” a conversion specifier.