我正在自动化我的一些报告,并且需要能够将文件上传到我有权访问的 SharePoint 目录。目标是让这个脚本通过任务计划程序运行(我已经知道如何设置)。
不知道从哪里开始,但我看到一些线程试图使用共享点和请求模块来执行此操作,但仍然有些卡住。
非常感谢任何帮助。谢谢。
请您参考如下方法:
我最终按照建议查找命令行方法,并将其组合在一起效果很好:
# maps local network drive to SharePoint directory (any open drive works)
os.system('net use r: {}'.format(sharepoint_url))
# uploads updated local file to SharePoint directory
os.system('copy {} r:\{}'.format(output_file_path, output_file_name))
# disconnects mapped network drive
os.system('net use r: /delete')
希望这对下线的人有帮助。
