V
V
Vlad Bahara2019-03-02 22:35:57
Python
Vlad Bahara, 2019-03-02 22:35:57

How to implement and pass a dynamic filename to a variable or directly?

There is a password generator. Below is the part that creates the file and puts the passwords in it. It is required to pass the created file to the record construction. But, because the file is created with datetime.now() , it can't be explicitly tracked and passed for writing.
Sorry for the inexperience. *** Newbie... what can I say ***
I would be grateful for your help)

os.mknod("passwords " + str(datetime.datetime.now().time()) + " .txt")

with open('passwords *** .txt', 'w') as f:
    for item in passHistory:
        f.write("%s\n" % item)

sizeFile = os.path.getsize('passwords.txt')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Forevka69, 2019-03-03
@vladbaharich

name = str(datetime.datetime.now().time())
os.mknod("passwords " + name + " .txt")

with open('passwords '+name+' .txt', 'w') as f:
    for item in passHistory:
        f.write("%s\n" % item)

sizeFile = os.path.getsize('passwords '+name+' .txt')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question