【问题标题】:Unsupported operand type(s) for %: 'NoneType' and 'tuple'% 不支持的操作数类型:“NoneType”和“元组”
【发布时间】:2016-10-17 17:43:23
【问题描述】:

我收到此错误:

TypeError: %: 'NoneType' 和 'tuple' 的操作数类型不受支持

我需要改变什么来解决这个问题?

string_1 = "Sean";
string_2 = "beginner programmer";

print("Hi my name is %s, I\'m a %s.") % (string_1,string_2);

【问题讨论】:

  • 另外,Python 中每一行的末尾都不需要;。 Python 使用缩进语法

标签: python


【解决方案1】:

print 返回None,您必须在打印之前格式化字符串

print("Hi my name is %s, I\'m a %s." % (string_1, string_2))

【讨论】:

    猜你喜欢
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 2011-11-22
    • 2016-09-07
    相关资源
    最近更新 更多