检查Julia中的文件是否存在

Ben*_*Ben 15 julia

在Julia中是否有一种简单的方法来检查当前工作目录中的文件是否存在(类似于test = os.path.isfile("foo.txt")Python或inquire(file = "foo.txt", exist = test)Fortran中的文件)?

Gom*_*ero 25

Julia具有isfile()测试常规文件的功能:

julia> isfile("foo.txt")
false

shell> touch foo.txt

julia> isfile("foo.txt")
true
Run Code Online (Sandbox Code Playgroud)

作为文件:

如果path(参数)是常规文件,则返回true,否则返回false.

  • 如此简单方便! (2认同)