저는 파이썬 3을 사용하고 있습니다.파일에 목록 쓰기 - 파일을 찾을 수 없습니다.
이 글은 필자가 작성하는 스크립트입니다. 이름/생일을 묻고, 그 입력을 받아서 목록에 추가합니다. 그런 다음 목록이 다른 파일에 기록됩니다.
나는 이것에 대한 연구를했는데 왜 효과가 없는지 찾을 수 없다.
print("""Enter the name and birthday of the person like this:
Adam 1/29
""")
all_birthdays = [ "none so far" ]
while True:
birthday = input("> ").upper()
if birthday == "":
break
if birthday == "LIST":
print(all_birthdays)
if birthday not in all_birthdays:
all_birthdays.append(birthday)
else:
print("This name/birthday is already known")
birthday_list = open('test.txt','w')
for bday in all_birthdays
birthday_list.write("%s\n" %bday)
SECOND 편집 :
여기 내 코드입니다 내가 코드를 추가 (가장 아래 루프와 작성 파일). 그것은 효과가 있었지만, 어디서나 파일을 찾을 수없는 것 같습니다. 어떤 도움이 필요합니까? 어떻게 찾아서 열 수 있습니까? Writing a list to a file with Python
()에 대한 함수 호출에 대괄호가 없습니다. 이 괄호를 추가하면 코드가 제대로 작동합니다. – Dartmouth
다트 마우스는'upper' 함수 호출을 의미합니다. – martineau