[英]Python ,TypeError: not all arguments converted during string formatting, SMB mount command
I am trying to smb mount using below script but facing "TypeError" issue can someone please help me to solve this. 我正在尝试使用以下脚本进行smb挂载,但面临“ TypeError”问题,有人可以帮助我解决此问题。 the actual command i want to execute is mount -t cifs //111.11.111.111/SMBShare /mnt -o username=admin,password=admin,vers=3.0 我要执行的实际命令是mount -t cifs //111.11.111.111/SMBShare / mnt -o username = admin,password = admin,vers = 3.0
python code: python代码:
#!/usr/bin/env python #!/ usr / bin / env python
def setup_env(self, get_xyz_share):
share = get_xyz_share.name
dx_ip = co.data_sols[0].address
co.clients[0].execute(['mount' ,'-t' ,'cifs' ,'//%s','/','%s' ,'/mnt', '-o' ,'username=admin,password=admin,vers=3.0' %(dx_ip, share)])
The script output looks like :--- 脚本输出看起来像:---
co.clients[0].execute(['mount' ,'-t' ,'cifs' ,'//%s','/','%s' ,'/mnt', '-o' ,'username=admin,password=admin,vers=3.0' %(dx_ip, share)]) TypeError: not all arguments converted during string formatting dx_ip = '111.11.111.111' get_xyz_share = <cx.models.Share.Shareobject at 0x4d53248 | name SMBShare>) self = TestMySMB share = 'SMBShare'
You do the conversion on the last element in the list: 您对列表中的最后一个元素进行转换:
'username=admin,password=admin,vers=3.0' %(dx_ip, share)
Which has no %s at all. 根本没有%s。
you probably want to do something like: 您可能想要执行以下操作:
co.clients[0].execute(['mount' ,'-t' ,'cifs' ,'//%s/%s' % (dx_ip, share) ,'/mnt', '-o' ,'username=admin,password=admin,vers=3.0'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.