[英]Python string formatting - TypeError
I'm new to python and currtly playing a little bit with it. 我是python的新手,现在有点用它了。
So I'm trying to use string formatting and get an error message for following code: 因此,我尝试使用字符串格式并收到以下代码的错误消息:
domain = 'myway.net'
inet = 'the internet'
line2 = "Play the way through %s using %s" (inet, domain)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
What doing I wrong? 我做错了什么?
Perhaps you're missing the format operator in between the string and the arguments? 也许您在字符串和参数之间缺少格式运算符? Try adding
%
in between: 尝试在两者之间添加
%
:
line2 = "Play the way through %s using %s" % (inet, domain)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.