开发者

Difference between 2 styles of closing file in Python

开发者 https://www.devze.com 2023-04-04 15:59 出处:网络
Can somebody please explain the difference between the following? handler = open(printFile, \"w\") handler.close()

Can somebody please explain the difference between the following?

handler = open(printFile, "w")        
handler.close()

and

handler = open(prin开发者_StackOverflow中文版tFile, "w")   
close(printFile)


The difference is pretty simple: The latter does not exist.

If it does in your application, it's user-defined and might just call firstArgument.close() or do something else such as killing your dog.

0

精彩评论

暂无评论...
验证码 换一张
取 消