Python程序不在文件中写入

2024-10-02 00:21:36 发布

您现在位置:Python中文网/ 问答频道 /正文

用户向程序提供输入,程序应将其写入文件将其上载到txt文件时出现问题

Plan = open("Plan.txt", "r")
content = Plan.read()
Plan_lista = content.split(",")
Przedmioty = []

Przedmioty = list(set(Plan_lista))
Przedmioty.remove("")
Plan.close()

#Dodawanie linków do listy
Linki = open("Linki.txt", "w+")

print("\n" + "Podaj Link do:")
a=0;
for i in range(len(Przedmioty)):
    print (Przedmioty[a], end = "\r")
    link = input(": ")
    Linki.write(Przedmioty[a] + "," + link)

    if ( a != len(Przedmioty)-1):
        Linki.write(", ")
    a+=1

Tags: 文件用户程序txtlenlinkopencontent

热门问题