我需要返回文件的內容,這樣做可以嗎:def foo(filePath): with open(filePath) as f: return json.load(f)或者我應該這樣做:def foo(filePath): with open(filePath) as f: r = json.load(f) return r(當然我的功能還可以做其他事情,這是一個玩具模型)
在“with”語句中返回危險嗎?
慕田峪9158850
2023-12-12 15:10:48