如何解决如何检查 PosixPath 是目录还是文件
使用 G01 +
geom_text_repel(aes(label = gsub("^.*$"," ",label)),# This will force the correct position of the link's right end.
segment.curvature = -0.1,segment.square = TRUE,segment.color = 'grey',box.padding = 0.1,point.padding = 0.6,nudge_x = 0.15,nudge_y = 1,force = 0.5,hjust = 0,direction="y",na.rm = TRUE,xlim = as.Date(c("2021-02-16","2021-03-01")),ylim = c(0,73.75),) +
geom_text_repel(data = . %>% filter(!is.na(label)),aes(label = paste0(" ",segment.alpha = 0,## This will 'hide' the link
segment.curvature = -0.1,# segment.color = 'grey',73.75))
我可以运行 Path
,我如何使用 path.is_dir()
做同样的事情?
解决方法
如何用 PosixPath
做同样的事情?
完全一样的方式。 PosixPath
extends Path
因此具有所有底层方法:
Python 3.9.0 (default,Oct 12 2020,02:44:01)
[GCC 9.3.0] on linux
Type "help","copyright","credits" or "license" for more information.
>>> import pathlib,os
>>> pathlib.PosixPath("/").is_dir()
True
>>> os.system("touch /tmp/aFile.txt")
>>> pathlib.PosixPath("/tmp/aFile.txt").is_dir()
False
>>> pathlib.PosixPath("/tmp/aFile.txt").is_file()
True
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。