-1
基本的にタイトルには次のようなものがあります。ファイル内のユーザー名とパスワードを検出するプログラムを作成しようとしています。私はそれを実行するたびにしかし、それはこのエラーを思い付く:ここリストオブジェクトには属性がありません。
Traceback (most recent call last):
File "C:/Users/tom11/Desktop/Data Login.py", line 33, in <module>
content = raw.split(",")
AttributeError: 'list' object has no attribute 'split'
は、それが間違って起こっているコードです:
UCheck = ""
PCheck = ""
Username = input("Username: ")
Attempts = 3
while UCheck != "Y":
lines = True
f = open('Data.txt', 'r+')
while lines:
raw = f.readlines()
content = raw.split(",")
if len(raw) == 0:
print("That Username does not exist!")
Username = input("Username: ")
elif Username == content[0]:
UCheck == "Y"
lines = False
これは、.txtファイルの内部にあるものです:
TheCloudMiner,Password123
TestUser,TestPass
Testing,Tester
Username,Password
私は他の回答をいくつか読んだことがありますが、私には役に立たないです。どんな助けでも大歓迎です。
'生=のf.readlines()'を返すリストではなく、文字列のようなもので、それを反復する必要がありますので、個別に各ライン上
split()
を適用したいです。また、 'f.readline()'を探しているようです。 –