Hi
On 25 December 2011 17:16, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> Hi list,
>
> In order to make tests I must create strings [20-32] & [32-64]
> characters long with accentuated characters.
>
> I use a very old piece of code (not even accurated, but sufficient
> until now), however it don't give me lower-case nor accentuated :
> for b in range(random.randint(48, 64)):
> chiffre = random.randint(65, 88)
> myStr += unichr(chiffre)
>
> Does somebody has such code?
How about something like this in Python:
#!/usr/bin/env python
# coding=utf-8
import random
def rand_string(length):
# All the characters you want to use in your strings:
test_chars = u"abcdeABCDE12345áàäéèëÁÀÄÉÈË -,."
s = []
for i in range(length):
s.append(random.choice(test_chars))
return "".join(s)
print rand_string(random.randint(48, 64))
--
Michael Wood <esiotrot@gmail.com>