In Python (2.7), why is os.remove not identical to os.unlink?
问题 >>> import sys >>> sys.version '2.7.3 (default, Mar 13 2014, 11:03:55) \n[GCC 4.7.2]' >>> import os >>> os.remove is os.unlink False >>> os.remove == os.unlink True Why is that? Isn't os.unlink supposed to be an alias of os.remove? 回答1: To answer this question we have to dive a bit into the details of how the python interpreter works. It might be different in other python implementations. First let's start where the os.remove and os.unlink functions are defined. In Modules/posixmodule.c they