# /usr/bin/env python
# -*- coding:utf-8 -*-
from smb.SMBConnection import SMBConnection
conn = SMBConnection('root', '123456', 'any', '', use_ntlm_v2 = True)
assert conn.connect('10.0.13.13', 445) #smb服务器地址
#sharelist = conn.listShares()
#for i in sharelist:
#print i
file_obj = open('F:/samba/123.c', 'wb') #保存到本地的路径和文件名
filesize = conn.retrieveFile('root', '/123.c', file_obj) #获取smb服务器上的文件名字
file_obj.close()
Pysmb:https://pypi.org/project/pysmb/1.1.25/
安装Pysmb以后不能直接用,还需要安装:pyasn1
Pyasn1: https://pypi.org/project/pyasn1/
也可以查看帮助文档路径是:https://pysmb.readthedocs.io/en/latest/