小编use*_*649的帖子

Python:TypeError:无法连接'str'和'int'对象

我有这个python程序,它将字符串添加到整数:

a = raw_input("Enter a: ")
b = raw_input("Enter b: ")
print "a + b as strings: " + a + b
a = int(a)
b = int(b)
c = a + b
str(c)
print "a + b as integers: " + c
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Python: TypeError: cannot concatenate 'str' and 'int' objects
Run Code Online (Sandbox Code Playgroud)

如何将字符串添加到整数?

python printing string integer

141
推荐指数
4
解决办法
30万
查看次数

TypeError:'builtin_function_or_method'对象是不可取消的?

嗨我有一个问题我不明白为什么我有一个类型错误请解释它是什么以及我如何解决它提前谢谢!

abb = raw_input("Abbreviation: ")
text = raw_input("Text: ")
text = text.lower().split()
abb = abb.lower().split
list1 = []
i = 0
j = 0

while i < len(text):
    for i in range(len(text)):
        if text[i].startswith(abb[0]):
            list1.append(text[i])
            for i in range(len(text)):
                if text[i].startswith(abb[1]):
                    list1.append(text[i])
                    for i in range(len(text)):
                        if text[i].startswith(abb[2]):
                            list1.append(text[i])
Run Code Online (Sandbox Code Playgroud)

python text types

0
推荐指数
1
解决办法
4329
查看次数

标签 统计

python ×2

integer ×1

printing ×1

string ×1

text ×1

types ×1