Open file and return a corresponding file object. If the file cannot
be opened, an OSError is raised.
file is a path-like object giving the pathname (absolute or relative
to the current working directory) of the file to be opened or an
integer file descriptor of the file to be wrapped. (If a file
descriptor is given, it is closed when the returned I/O object is
closed, unless closefd is set to False.)
您可以使用找到(会话或脚本的)当前工作目录
如果
NewFile
仍然存在(即使关闭)提供文件的完整路径。你知道吗
Document:
在执行此脚本的同一目录中。你知道吗
如果您不是从命令行运行这个,那么请尝试使用“os”模块中的方法打印当前工作目录。你知道吗
相关问题 更多 >
编程相关推荐