简体   繁体   English

Python字符串格式-TypeError

[英]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.

相关问题 字符串格式代码中的Python TypeError - Python TypeError in string formatting code Python TypeError:字符串格式的参数 - Python TypeError: argument to string formatting Python 程序的类型错误(字符串格式为 %d) - TypeError for Python program (string formatting with %d) python格式字符串TypeError:在字符串格式化期间不是所有参数都被转换 - python format string TypeError: not all arguments converted during string formatting 带有百分比的 Python 字符串格式(“TypeError:格式字符串的参数不足”) - Python string formatting with percentage ("TypeError: not enough arguments for format string") TypeError:在字符串格式化字符串python期间,并非所有参数都已转换 - TypeError: not all arguments converted during string formatting string python Python TypeError:使用witn open()时的字符串格式 - Python TypeError:string formatting when use witn open() Python MySQLdb Insert TypeError:在字符串格式化期间并非所有参数都已转换 - Python MySQLdb Insert TypeError: not all arguments converted during string formatting Python列表中的“ TypeError:并非在格式化字符串时转换了所有参数” - “TypeError : not all arguments converted during string formatting” in a Python list Python3“TypeError:不是在字符串格式化期间转换的所有参数” - Python3 “TypeError: not all arguments converted during string formatting”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM