File names may contain a user and host specification to indicate that
the file is to be copied to/from that host. Local file names can be made
explicit using absolute or relative pathnames to avoid scp treating file
names containing ‘:’ as host specifiers.
唯一的方法是使用启发式方法,因为ssh路径也是有效的文件名(尽管非常奇怪)。在
根据scp文档:
所以检查它们是否以显式路径开始,或者在正确的位置没有冒号。然后假设它是本地路径,否则假设它是远程路径。在
示例:
你可以这样做-
user@host1:/data/bla.txt
)这样的路径。在SSH
路径Y(另外还要检查“@”和“:”,因为否则该文件在任何计算机中都不存在)。在使用glob根据模式列出文件。在
如果路径是现有的常规文件,^{} 返回
True
。所以它用于检查文件是否已经存在并且不支持通配符。glob
可以。 要检查路径是否是本地文件系统中的现有文件,请使用:相关问题 更多 >
编程相关推荐