Wickeln Sie zwei Array in eine andere Variable [Duplikat]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wickeln Sie zwei Array in eine andere Variable [Duplikat]

by Anonymous » 12 Mar 2025, 03:33

Ich hatte eine Funktion namens ReadFile codiert, hat zwei Array -Liste, aber ich kann nicht zwei Array zurückgeben. Daher muss ich es in die Objektvariable einwickeln und zurückgeben.
unten ist mein Code: < /p>
def __init__(self, environment):
super().__init__(environment)
self.loginUsername = []
self.loginPassword = []
self.loginInfo = None

def on_start(self):
self.readfile()

def readfile(self):
try:
with open("users.txt", "r") as loginFile:
for line in loginFile:
username, password = line.strip().split(',')
self.loginUsername.append(username)
self.loginPassword.append(password)

except FileNotFoundError:
print("The file user.txt does not exist.")
except Exception as e:
print(f"An error occurred: {e}")

return self.loginInfo
< /code>
Bitte helfen Sie. Vielen Dank im Voraus.

Top