有没有办法检查是否使用python regex隐藏了给定的文件/文件夹路径并过滤了隐藏的.sync / .archive数据:
`filepath1 = "/home/ubuntu/.file"`
`filepath2 = "/home/ubuntu/.archiveddata"`
`filepath3 = "/home/ubuntu/.folder"`
if filepath1 matches with pattern:
it is hidden file/folder
else:
it is archived data
答案 0 :(得分:2)
你可以试试这个:
import re
filepath = "/home/ubuntu/.myfile.txt"
is_hidden = bool(re.search(r'/\.[^/]+$', filepath))
print(is_hidden)