How do I change a UUID to a string?

Alphin Philip picture Alphin Philip · May 5, 2016 · Viewed 65.4k times · Source

I need to be able to assign a UUID to a user and document this in a .txt file. This is all I have:

import uuid
def main():
    a=input("What's your name?")
    print (uuid.uuid1())
    f.open(#file.txt)
main()

I tried:

f.write(uuid.uuid1())

but nothing comes up, may be a logical error but I don't know.

Answer

sumit picture sumit · May 5, 2016

you can try this !

 a = uuid.uuid1()
 str(a)
 --> '448096f0-12b4-11e6-88f1-180373e5e84a'