os.access与通配符 [英] os.access with wildcards
本文介绍了os.access与通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用
os.access(路径,模式)
其中path可能包含linux样式的通配符。
到目前为止我已经失败了。
我的解决方法是bash命令。
os.system(''[ -e%s]''%fn)
有什么建议吗?
i''d like to use
os.access(path,mode)
where path may contain linux style wildcards.
i''ve failed so far.
my workaround is the bash command.
os.system(''[ -e %s ]'' % fn )
any suggestions?
推荐答案
mike写道:
我想使用
os.access(路径,模式)
其中path可能包含linux样式的通配符。
i''d like to use
os.access(path,mode)
where path may contain linux style wildcards.
os.access(glob.glob(路径),模式)
os.access(glob.glob(path), mode)
谢谢Leif。我的问题很糟糕。
我一直在使用
glob.glob(路径)== []
并且正在寻找更具可读性的东西,因此
os.system(''[ - e%s]''%path}
但这似乎不是跨平台的好习惯。
我以为可能有办法逃脱通配符,或者
替代os.access,或....
任何其他想法?
thanks Leif. poor question on my part.
I had been using
glob.glob(path)==[]
and was looking for something more readable, hence
os.system(''[ -e %s ]'' % path )
but that doesn''t seem like a good idiom for crossplatform.
I thought there may either be a way to escape the wildcards, or an
alternative to os.access, or ....
any othr ideas?
谢谢Leif。我的问题很糟糕。
我一直在使用
glob.glob(路径)== []
并且正在寻找更具可读性的东西,因此
os.system(''[ - e%s]''%path}
但这似乎不是跨平台的好习惯。
我以为可能有办法逃脱通配符,或者
替代os.access,或....
任何其他想法?
thanks Leif. poor question on my part.
I had been using
glob.glob(path)==[]
and was looking for something more readable, hence
os.system(''[ -e %s ]'' % path )
but that doesn''t seem like a good idiom for crossplatform.
I thought there may either be a way to escape the wildcards, or an
alternative to os.access, or ....
any other ideas?
这篇关于os.access与通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文