file_path中的路径中有两个日志,我想使用python读取它们
D:\编码\ iRoiro \ chuckrep文件夹中有a,b,c,d的文件夹,其中还有e,f,g,h hh folder。并且在此E,F,G,H文件夹中有C000日志和W日志,我想单独将它们带入其中,但是我不知道我设计的代码是错误的还是什么都不是。
file_path = './ChuckRep/*/*/'
file_name, ext = os.path.splitext(file_path)
for path in glob.glob(file_path):
if ext=='.smm_logs':
cfile_path = glob.glob(file_name[:-4]+'C000.smm_logs')[0]
wfile_paths = glob.glob(file_name[:-4]+'*W*.smm_logs')
print(cfile_path)
如何打印cfile_path和wfile_path以获取结果?
There are a,b,c,d folders in the D:\Coding\iroiro\ChuckRep folder, and there are also e,f,g,h folders in it. And there are C000 logs and W logs in this e,f,g,h folder, and I want to bring them in individually, but I don't know if the code I designed is wrong or nothing.
file_path = './ChuckRep/*/*/'
file_name, ext = os.path.splitext(file_path)
for path in glob.glob(file_path):
if ext=='.smm_logs':
cfile_path = glob.glob(file_name[:-4]+'C000.smm_logs')[0]
wfile_paths = glob.glob(file_name[:-4]+'*W*.smm_logs')
print(cfile_path)
How can I print cfile_path and wfile_path to get the result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
file_path
类似glob的,则只会获得目录。os.walk()< /code>
,我会说这对初学者而言不那么困惑。
file_path
glob-like, you get only directories.os.walk()
, I'd say it's less confusing for beginner.