小编wis*_*ert的帖子

为什么Python在返回结果时显示"绑定方法...."如何让它停止?

我一直在寻找我正在寻找的答案bound method tramStop.returnUpcomingTimes of <__main__.tramStop instance at 0x141d030>.

我收到我的时间信息很长一段时间,我将=设置为变量SabinesTimes,然后将其从字符串转换为列表(以便能够遍历时间而不是字符).

这是我的代码:

from datetime import datetime
from time import strftime
import shlex # <http://stackoverflow.com/questions/6868382/python-shlex-split-ignore-single-quotes> 
import types

# SabinesTimes is given to me as one long string, I need to iterate through each time and compare to current time.  So I convert it to a comma delineated list. 

SabinesTimes = "04:55 05:55 06:10 07:20 08:35 09:45 10:58 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:59"
SabinesTimes …
Run Code Online (Sandbox Code Playgroud)

python methods

5
推荐指数
1
解决办法
9275
查看次数

如何在Python中正确返回类实例列表

class ligne():
    def __init__ (self, stops):
        ##stops = a list of instances of Ligne1Stop class
        self.stops = stops
    def returnAllStopsOnLigne(self):
        return self.stops
Run Code Online (Sandbox Code Playgroud)

当我调用方法returnAllStopsOnLigne()时,我得到一个列表

"<__main__.ligne1Stop instance at 0x1418828">
Run Code Online (Sandbox Code Playgroud)

如何在停止列表中返回正确的类实例名称?

python class list

2
推荐指数
1
解决办法
150
查看次数

标签 统计

python ×2

class ×1

list ×1

methods ×1