Hello, I am having a problem with my fhand=open() codes I don’t really know why but the code itself is not working, it can’t detect the .txt file even if they are in the same folder. what should I do here is my code and the error it gives to me.
The code:
ffile=input('ENTER THE FILE''S NAME...:')
fhand=open('file.txt')
sayiLine=0
uzunluk=fhand.read()
for line in fhand:
sayiLine=sayiLine+1
line=line.rstrip()
if not line.starswith('A'):
continue
c=input('Dosyanda :', sayiLine,'kadar satır bulunuyor.')
d=input('Dosyanda :', uzunluk,'kadar karakter mevcut, VE BOŞLUKLAR BUNA DAHİL!!')
f=input('Son olarak dosyanda aramış olduğun tüm satırlar şunlar:')
print(line)
g=input('Çıkmak için enter tuşuna basabilirsin')
The error:
Traceback (most recent call last):
File "c:\Users\PC\Desktop\PYTHON FALL\deneme.py", line 4, in <module>
uzunluk=fhand.read()
File "C:\Users\PC\AppData\Local\Programs\Python\Python310\lib\encodings\cp1254.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9e in position 97: character maps to <undefined>