五、监听共享目录文件
#!/usr/bin/python # -*- coding: utf-8 -*- import os; import glob; def login_share(ip, user, password): try: cmd = 'net use \\\\%s\\ipc$ "%s" /user:"%s"'%(ip, password, user) #print('loging share: %s'%cmd); os.system("net use * /del /y"); os.system(cmd); return True; except ValueError: return False; login_share("172.17.2.198","wsy","123"); def getDir(url): try: #list=os.listdir(url); list= glob.glob(url+'/*.xml') for temp in list: print(temp); return True; except ValueError: print("读取目录错误:"+ValueError); return False; getDir("//172.17.2.198/wsy1"); input("");