Tip of the day generator.
Diez B. Roggisch
deets at nospam.web.de
Wed Nov 28 11:07:53 EST 2007
Joseph king wrote:
> Hey i was wondering if any one would know if there was a way to have
> python randomly read form a file or would you ahve to know the byte
> postion and somehow randomize splicing the file so the sentence you
> want show's up.
>
> i.e have a file with a lot of tips and useless facts and then have
> python randomly read one sentence when the code is run and print at
> any time you would want it to.
import random
print random.choice(open("quotes").readlines())
Diez
More information about the Python-list
mailing list