Python 如何在不使用%s的情况下调用各种字符串? 这很有效。但我想知道它是否使用字典来调用字符串
Python 如何在不使用%s的情况下调用各种字符串? 这很有效。但我想知道它是否使用字典来调用字符串,python,Python,print(“学习%(语言)s%(与谁一起)”%({'language':text1},{'where':text2})) 但它不起作用。我怎样才能修好它 错误显示“格式需要映射”如果您注意到以下情况,则该错误会起作用: 你忘了在%(和谁一起)-->%(和谁一起)s后面加一个s 而不是这个%({'language':text1},{'with where':text2})-->{'language':text1,'with where':text2} 所以这条线是这样的: text1="Pyth
print(“学习%(语言)s%(与谁一起)”%({'language':text1},{'where':text2}))
错误显示“格式需要映射”如果您注意到以下情况,则该错误会起作用:
%(和谁一起)
-->%(和谁一起)s后面加一个s
%({'language':text1},{'with where':text2})
-->{'language':text1,'with where':text2}text1="Python"
text2="with me"
print("Study %(language)s" %{'language':text1})
如果你注意到:
%(和谁一起)
-->%(和谁一起)s后面加一个s
%({'language':text1},{'with where':text2})
-->{'language':text1,'with where':text2}text1="Python"
text2="with me"
print("Study %(language)s" %{'language':text1})