import os
students={}
def kayit(): #registration scripts
global studentNumber,studentName,stundentSurname,studentPhone
studentNumber=input("\nNumara giriniz:")
studentName=input("\nİsim giriniz:")
stundentSurname=input("\nSoyisim giriniz:")
studentPhone=input("\nTelefon giriniz:")
students.update({studentNumber:{
"Ad:": studentName,
"Soyad:":stundentSurname,
"Telefon:":studentPhone
}
})
studentsText=open("studentsText.txt","a")
studentsText.write(str(students))
studentsText.close()
os.system("cls")
main()
def sorgu(): #check scripts
check=input("\nÖğrenci numarasını giriniz:")
studentsText1=open("studentsText.txt","r")
veri=studentsText1.read()
dictveri=dict(veri)
studentsText1.close()
if check in dictveri[0]:
checkprint=f'İsim: {students[check]["Ad:"]}\nSoyisim: {students[check]["Soyad:"]}\nTelefon: {students[check]["Telefon:"]}'
print(checkprint)
elif check not in dictveri[0]:
print("\nYanlış numara girdiniz!")
input()
os.system("cls")
main()
def islem(): #1 or 2
global choose
choose=int(input("\nİşlemi giriniz:"))
def main(): #Main code
print(""" Öğrenci numarası sorgulamak için 1'e,
Öğrenci kaydetmek için 2 ye basınız""")
islem()
if choose == 1:
sorgu()
elif choose==2:
kayit()
main()
Küçük bir öğrenci kayıt sistemi geliştiriyorum. Kaydedilen öğrencileri text dosyasına yazdırmayı başardım. Ama öğrenci sorgularken bu text dosyasından veriyi dict olarak almam gerekiyor.Kodu çalıştırdığımda ise dictveri=dict(veri)
satırını işaretleyerek ValueError: dictionary update sequence element #0 has length 1; 2 is required
hatası veriyor.
Bu text dosyasından verileri nasıl dict olarak alırım?