2👍
✅
Instead of this –
file = open(f, 'r').read()
try
file = open(f.name, 'r').read()
You are passing the file object whereas the function needs file path/name.
Source:stackexchange.com