Warum gibt er mir diese Antwort zurück: TypeError: 'str'-Objekt kann nicht als Ganzzahl interpretiert werden [Duplikat]
Posted: 06 Jan 2025, 04:54
Code: Select all
from os import *
cwd = getcwd()
basename = input('Enter file name: ')
file = str(cwd + '/' + basename)
if path.isfile(file):
with open(file, "r") as rf:
content = f.readline()
print(content)
Code: Select all
Enter file name: anything
Traceback (most recent call last):
File "C:\\test.py", line 6, in
with open(file, "r") as rf:
~~~~^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer