【问题标题】:How to delete a file from the working directory in Julia?如何从 Julia 的工作目录中删除文件?
【发布时间】:2018-08-12 09:43:20
【问题描述】:

如何从 Julia 的当前目录中删除文件?

R中是否有像file.remove()这样的直接函数?

【问题讨论】:

    标签: file julia file-management file-manipulation


    【解决方案1】:

    是的,有rm。请参阅 Julia in-REPL 帮助(通过按 ? 访问):

    help?> rm
    search: rm permute! normpath permutedims permutedims! PermutedDimsArray uperm operm gperm isperm powermod VecOrMat invperm invpermute! rem rem2pi argmin argmax promote promote_type promote_rule promote_shape
    
      rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
    
      Delete the file, link, or empty directory at the given path. If force=true is passed, a non-existing path is not treated as error. If recursive=true is passed and the path is a directory, then all contents
      are removed recursively.
    
      Examples
      ≡≡≡≡≡≡≡≡≡≡
    
      julia> mkpath("my/test/dir");
    
      julia> rm("my", recursive=true)
    
      julia> rm("this_file_does_not_exist", force=true)
    
      julia> rm("this_file_does_not_exist")
      ERROR: IOError: unlink: no such file or directory (ENOENT)
      Stacktrace:
      [...]
    

    所以你可以做rm(filename)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-15
      • 1970-01-01
      • 2011-03-14
      • 2015-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多