-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()'返回列表,而不是字符串。另外,看起來你正在尋找'f.readline()' –