Skip to main content
 首页 » 编程设计

python之'net' 在 python 中不是内部或外部命令,也不是可运行的程序或批处理文件

2024年10月24日18grandyang

我正在尝试连接到网络驱动器, 我写了下面的代码。 但我正在获取 'net' 未被识别为内部或外部命令

import copy,random, unicodedata, re, os 
import subprocess, netrc 
 
password  = "MyPWD" 
domain_name = "MyDomain" 
user_name = "MyName" 
subprocess.call(r'net use m: /del', shell=True) 
os.system(r"NET USE m: \\fileshare\\Users\\Dir %s /USER:%s\%s" % (password, domain_name, user_name)) 

请您参考如下方法:

遇到了同样的问题。 @kindall 的评论让我走上了解决这个问题的正确轨道,但对我来说路径是 %windir%\SysWOW64\net