0
私のクラスプロジェクトでは、簡単なユーザーネームのInventorを作成し、ユーザー名をファイルに保存する必要があります。これは私がやったことであり、働いています。テキストファイルの重複を#で置き換える方法は?
プロジェクトに追加される部分は、ファイルに複製が追加された場合、その複製を削除して "#"に置き換える必要があることです。しかし、 "#"は複製された元のユーザー名の隣になければなりません。
は、誰かが参考のために、これは以下の私のコードであるとして、これを行う方法を私を見ることができますしてください:
print("Hello, Welcome to the Username Inventor.")
Name = input("Please tell me, What is your name? ")
print(Name+"......")
print("I like....")
print("Anyway, lets get on shall we.")
with open("Interim.txt", "a") as file:
true = True
while true == True:
choice = input("(1)Add a Pupil's Username to the file\n(2)Exit the program\n")
if choice == "1":
true = False
print("Please identify the following:")
FirstName = input("Pupil's First Name: ")
Surname = input("Pupil's Surname: ")
YearOfEntry = input("Pupil's Year of Entry: ")
print("Thank you",FirstName, Surname, "from year joining at",YearOfEntry+".")
Initial = FirstName[0]
Username = YearOfEntry+Surname+Initial
print("This Pupil's Username is",Username+".")
file.write(Username)
file.write("\n")
true = True
if choice == "2":
print("Thank you", Name+". Goodbye!")
true = False
ヘルプはどうもありがとうございました、理解されるであろう。