gpt4 book ai didi

python - % : 'NoneType' and 'tuple' 不支持的操作数类型

转载 作者:行者123 更新时间:2023-12-04 12:13:50 24 4
gpt4 key购买 nike

我收到此错误:

TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'



我需要改变什么来解决这个问题?
string_1 = "Sean";
string_2 = "beginner programmer";

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

最佳答案

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

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

关于python - % : 'NoneType' and 'tuple' 不支持的操作数类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40092556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com