Tôi là người mới bắt đầu trong python. Tôi không thể hiểu vấn đề là gì?AttributeError: đối tượng 'tuple' không có thuộc tính
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()
Các lỗi tôi nhận được là:
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'
không có điều gì hoàn hảo ... chỉ cần gọi hàm và chức năng đó thực hiện phần còn lại – Gogo
Điều đó không liên quan đến mã bạn đã đăng ở đây. Cái gì khác phải là vấn đề –
thats toàn bộ mã ... kiểm tra liên kết nếu u muốn ... [link] (http://codepad.org/yQXHzIbE) – Gogo