我有这个简单的python 3.x代码:
str = "{} ({}) is already aliased to {} ({})".format(nodeName, node['ipAddress']), n2['dnsName'], n2['ipAddress'])
format()的所有4个参数都是字符串,但我收到此错误:
str = "{} ({}) is already aliased to {} ({})".format(nodeName, node['ipAddress'], n2['dnsName'], n2['ipAddress'])
ValueError: zero length field name in format
如果我只使用print()手动打印节点[' ipAddress']和节点[' dnsName'],我会看到:
dnsName = yuckyre.foobar.com
ipAddress = 192.168.1.10
<type 'str'>
不确定为什么&#34;出现&#34 ;.也许这是问题的线索?