[Python] Making a dir using uuid as a directory in python 3

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    import os
    import uuid

    wallet_filepath = os.path.join( 'PWD', str(uuid.uuid4().hex) , '.bin')
    print (wallet_filepath)
    print (os.path.exists(wallet_filepath))
    print (os.stat(wallet_filepath))


    This is the OUTPUT that I am getting from this code.

    /home/user/randomTests/b1c51a61c235479aa0964e14db7135d6/.bin

    False

    Traceback (most recent call last):
    File "testDir.py", line 9, in <module>
    print (os.stat(wallet_filepath))
    FileNotFoundError: [Errno 2] No such file or directory: '/home/user/randomTests/b1c51a61c235479aa0964e14db7135d6/.bin'

    Continue reading...

Compartilhe esta Página