各位大大
小弟想測試生成bat檔連線網路磁碟機
網與磁碟機需用網域帳號驗證
net use I: /delete
net use I: \192.1.1.95\AccessDB /user:bus\ABC "QQ@123"
txt_01磁碟機I
txt_02是磁碟機路徑
txt_03是帳號
txt_04是密碼
只是當我要指定txt_05 = "/user:bus\ " 就有問題
\後面一定要有空格 否則資料型態就會有問題
只是這樣BAT語法就會出錯
請教各位大大 有什麼方法可以解決
感激不盡
以下是部分程式碼
txt_05 = "/user:bus\ "
txt_05 = txt_05.rsplit()
print(txt_05)
# 创建 BAT 文件
with open("run"+txt_01+".bat", "w") as d:
d.write("net use "+txt_01+": /delete")
d.write('\r\n')
d.write("net use "+txt_01+": "+txt_02+" "+txt_05+""+txt_03+" "+txt_04+"")
# 执行 BAT 文件
subprocess.call("run"+txt_01+".bat", shell=True)
錯誤訊息
d.write("net use "+txt_01+": "+txt_02+" "+txt_05+""+txt_03+" "+txt_04+"")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
TypeError: can only concatenate str (not "list") to str