Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving information
#4
Okay so I know this code will look really basic and have a bunch of stuff that may be unnecessary/un-efficient, but keep in mind it is my first program. I have another python file named "User" and a text file called "passwords." I'm trying to save the passwords and usernames that the user inputs to the text file in the code at the bottom. Instead I get this: <User.User object at 0x10ae8b7f0>

from User import User
select = input("Enter login/register: ")


def password():
    password = ""
    return password

def username():
    username = ""
    return username

user1 = User(password, username)

if select == "login":
    username = input("Username: ")
    password = input("Password: ")
elif select == "register":
    def translate(password):
        translation = ""
        for letter in password:
            if letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890":
                if letter.isupper():
                    translation = translation + "*"
                else:
                    translation = translation + "*"
            else:
                translation = translation + letter
        else:
            for letter in password:
                if letter in "`~!@#$%^&*()_-+=\|{}[];':,./<>?":
                    print("Error: invalid password character")
        return translation

    username = input("Please make a username: ")
    print("Your password may contain any combination of uppercase and lowercase letters and numbers.")
    password = print(translate(input("Please make a password: ")))
else:
    print("invalid selection.")



appendMe = user1
appendFile = open("passwordsFile.txt)", "a")
appendFile.write(str(appendMe))
appendFile.close



class User:
    def __init__(self, username, password):
        self.username = username
        self.password = password
The class User code is from the file User.
Reply


Messages In This Thread
Saving information - by Justice_py - Nov-15-2019, 04:35 PM
RE: Saving information - by Larz60+ - Nov-15-2019, 05:06 PM
RE: Saving information - by jefsummers - Nov-15-2019, 05:37 PM
RE: Saving information - by Justice_py - Nov-16-2019, 01:34 AM
RE: Saving information - by jefsummers - Nov-17-2019, 02:35 AM
RE: Saving information - by Justice_py - Nov-26-2019, 02:08 AM
RE: Saving information - by buran - Nov-26-2019, 03:14 AM
RE: Saving information - by Justice_py - Nov-26-2019, 04:37 AM
RE: Saving information - by jefsummers - Nov-26-2019, 01:16 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020