A. fid = open("test.txt","w+")fid.close()fid.closed B. fid = open("test.txt","w+")fid.closedfid.close() C. with open("test.txt","w+") as fid:passfid.closed
A. 打开文件进行读写时可能出现异常,只使用open()函数可能导致最后不能正常关闭文件 B. with语句用来进行异常处理,相当于在调用open()函数后执行try和finally语句 C. 返回值是True D. 相当于执行 fid =open("test.txt","w+")