【问题标题】:Why does glob not work on a DFS share with command line administrator mode?为什么 glob 在命令行管理员模式下的 DFS 共享上不起作用?
【发布时间】:2016-06-07 16:24:36
【问题描述】:

我有一个包含几个 xml 文件的 DFS 网络共享,我编写了一个 python 脚本,它将使用 glob 获取我的 xml 文件

以下是我的DFS结构

├─ O
├──── my_path
|      ├── test1.xml
|      ├── test1.xml
|      └── test2.xml

以下是我的代码:

import glob

path = 'O:\\my_path\\*.xml'
files = glob.glob(path)
print 'Files found: {}'.format(len(files))

当我通过命令行运行它时,一切正常。

python test.py
> Files found: 3

但是,当我通过命令行管理员模式运行它时,它无法正常工作

python test.py
> Files found: 0

glob 在管理员模式下无法正常工作的原因是什么?解决方法是什么?

【问题讨论】:

    标签: python glob


    【解决方案1】:

    试试这个:

    import glob
    import os
    
    path = os.path.join('O:', 'my_path', '*.xml')
    print(path)
    files = glob.glob(path)
    print 'Files found: {}'.format(len(files))
    

    【讨论】:

      猜你喜欢
      • 2020-06-16
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 1970-01-01
      • 2015-12-16
      • 2021-06-14
      相关资源
      最近更新 更多