Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python で linecache を使用して行を取得しようとすると。
loginpass = raw_input("> ") if loginpass == linecache.getline('Password.txt', 1):
取得した行は常に追加の行で返されます。したがって、1 行目が
"Test"
戻る
"Test "
コードの前半では機能しましたが、その後はその行を追加します。
これは正常です; ファイルからの行の読み取りには、行末の改行文字が含まれます。剥がすだけです:
linecache.getline('Password.txt', 1).rstrip('\n')
ただし、パスワードをプレーンテキストで保存していることの方が心配です....