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