admin管理员组文章数量:1661414
我想使用Python语言从给定的FileShare位置获取文件名列表(仅限)。这是我的代码片段,但它没有列出任何文件。在import os
from os import walk
SQLSR_USER= 'username'
SQLSR_PASS= 'password'
BACKUP_REPOSITORY_PATH= '\\fileshare\location'
fileList = []
backup_storage_available = os.path.isdir(BACKUP_REPOSITORY_PATH)
if backup_storage_available:
print("Backup storage already connected.")
else:
print("Connecting to backup storage.")
mount_command = "net use /user:" + SQLSR_USER + " " + BACKUP_REPOSITORY_PATH + " " + SQLSR_PASS
os.system(mount_command)
backup_storage_available = os.path.isdir(BACKUP_REPOSITORY_PATH)
if backup_storage_available:
print ("Connection success.")
else:
raise Exception("Failed to find storage directory.")
for (dirpath, dirnames, filenames) in walk(backup_storage_available):
fileList.extend(filenames)
break
if (len(fileList) > 1):
print "\n\n *********************Required data files are present in the FileShare*********************"
else:
print "\n\n ********************* No files are present to start the Next Run *********************"
我仍然有一个网络使用连接命令列出的问题
^{pr2}$
版权声明:本文标题:python访问带密码的共享文件夹_Python使用用户名和密码访问并列出网络共享中的文件... 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729930952a1216749.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论