def read_lines():
readFileName = "readfile.txt"
f = open(readFileName, 'r+')
contents = f.read()
... # and so on
read_lines()
当我运行它时,我得到一个错误:
f = open(readFileName, 'r+')
UnboundLocalError: local variable 'open' referenced before assignment