【发布时间】:2018-08-12 09:43:20
【问题描述】:
如何从 Julia 的当前目录中删除文件?
R中是否有像file.remove()这样的直接函数?
【问题讨论】:
标签: file julia file-management file-manipulation
如何从 Julia 的当前目录中删除文件?
R中是否有像file.remove()这样的直接函数?
【问题讨论】:
标签: file julia file-management file-manipulation
是的,有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)。
【讨论】: