Warum gibt er mir diese Antwort zurück: TypeError: 'str'-Objekt kann nicht als Ganzzahl interpretiert werden [Duplikat]Python

Python-Programme
Anonymous
 Warum gibt er mir diese Antwort zurück: TypeError: 'str'-Objekt kann nicht als Ganzzahl interpretiert werden [Duplikat]

Post by Anonymous »

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)
Fehler:

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
Ich versuche, den Import zu ändern, aber das gleiche Ergebnis.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post