// 代码
thisset = set(("Google", "Running", "Taobao"))
print("length = "+ len(thisset))
// 报错
Traceback (most recent call last):
File "D:\python\hello.py", line 276, in <module>
print("length = "+ len(thisset))
TypeError: can only concatenate str (not "int") to str
python并不能像java一样,在做拼接的时候自动把类型转换为string类型,需要再int型前调用str()转换为str的方法。
修改如下:
thisset = set(("Google", "Runoob", "Taobao"))
print("length = "+ str(len(thisset)))