本文介绍了在已挂载共享的OSX中获取"unc"路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在python中,我试图获取已挂载共享的'unc'路径或服务器路径.因此,我的份额越来越大:

In python I am trying to get the 'unc' path or server path of a mounted share.So I have a mounted share of:

/Volumes/D

如何使用Python解决此问题:

How do I resolve to this with Python:

//192.168.0.7/D

干杯.

推荐答案

研究了df之后,我想到了在OSX上效果很好的解决方案:

After looking into df, I came up with this which works excellent on OSX:

from subprocess import Popen, PIPE

df = Popen('df -P /Volumes/link/to/some/folder', shell=True, stdout=PIPE)
serverAddress = df.stdout.readlines()[1:][0]
serverAddress = serverAddress.split('@')[1]
serverAddress = serverAddress.split('/')[0]
print serverAddress

这篇关于在已挂载共享的OSX中获取"unc"路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:39