<__ main __。CloudTravel对象位于0x000000D30F609828>不可迭代

时间:2019-02-17 04:37:20

标签: python-3.x

.py

a = (0,0,70)
b = (90,0,45)
c = ("1 2","0 2","0 1")
d = 0
e = 1

class Travel(object):

    def trip(self,latitude,longitude,canTravel,origin,destination):
        self.latitude    = latitude
        self.longitude   = longitude
        self.canTravel   = canTravel
        self.origin      = origin
        self.destination = destination
        print(latitude)
        print(longitude)
        print(origin)
        print(destination)
        print(canTravel)
        for c in canTravel:
            print(c)
        pass


c = Travel()
c.trip(a,b,c,d,e)

输出

(0, 0, 70)
(90, 0, 45)
0
1
<__main__.Travel object at 0x000000E836D25898>
Traceback (most recent call last):
  File ".\shortestpath.py", line 26, in <module>
    c.trip(a,b,c,d,e)
  File ".\shortestpath.py", line 20, in trip
    for c in canTravel:
TypeError: 'Travel' object is not iterable

我想将字符串(“ 1 2”,“ 0 2”,“ 0 1”)的元组传递给跳闸函数,并希望对其进行迭代。

如何遍历<< strong> main 。旅行对象位于0x000000E836D25898>

0 个答案:

没有答案