要检查文件是否不存在,等同于Python的文件if not os.path.exists(filename):if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { // path/to/whatever does not exist}要检查文件是否存在,等同于Python的文件if os.path.exists(filename):编辑:根据最近的评论if _, err := os.Stat("/path/to/whatever"); err == nil { // path/to/whatever exists} else if os.IsNotExist(err) { // path/to/whatever does *not* exist} else { // Schrodinger: file may or may not exist. See err for details. // Therefore, do *NOT* use !os.IsNotExist(err) to test for file existence}