Building off of @Anon's suggestion:
# Drive letter: M
# Shared drive path: \sharedfolder
# Username: user123
# Password: password
import subprocess
# Disconnect anything on M
subprocess.call(r'net use m: /del', shell=True)
# Connect to shared drive, use drive letter M
subprocess.call(r'net use m: \sharedfolder /user:user123 password', shell=True)
I prefer this simple approach, especially if all the information is static.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…