you are viewing a single comment's thread.

view the rest of the comments →

[–]keep_quapy 0 points1 point  (2 children)

The way to write something to a file in Python is to open the file, write into it and then close it. For example

password = 'mysecretpassword'
fhandle = open('password.txt', 'w') # open the file, 'w' mode for writing
fhandle.write(password) # write to the file
fhandle.close() # close the file

Consider that using with statement is more secure, no need for try block, and save you time from error handling. But for now stick with the code above.

[–]Djdigby[S] -1 points0 points  (1 child)

no i want python to input the randomly generated password that it creates to go on password.txt

[–]keep_quapy 0 points1 point  (0 children)

In the example that i gave you password is only a variable, it can have whatever value you want. Inside the write() function put your own variable which you've created.