【发布时间】:2013-06-21 19:46:29
【问题描述】:
我是python的初学者。我无法理解问题所在?
def list_benefits():
s1 = "More organized code"
s2 = "More readable code"
s3 = "Easier code reuse"
s4 = "Allowing programmers to share and connect code together"
return s1,s2,s3,s4
def build_sentence():
obj=list_benefits()
print obj.s1 + " is a benefit of functions!"
print obj.s2 + " is a benefit of functions!"
print obj.s3 + " is a benefit of functions!"
print build_sentence()
我得到的错误是:
Traceback (most recent call last):
Line 15, in <module>
print build_sentence()
Line 11, in build_sentence
print obj.s1 + " is a benefit of functions!"
AttributeError: 'tuple' object has no attribute 's1'
【问题讨论】:
-
不,它完全没问题..它只是调用函数,其余的由该函数完成
-
这与您在此处发布的代码无关。其他问题一定是问题
-
这就是整个代码...如果您愿意,请检查链接...link
-
由于您使用
print语句调用了build_sentence()函数,并且由于该函数没有返回任何内容,所以None。
标签: python python-2.7