相关疑难解决方法(0)

测量Python中经过的时间?

我想要的是开始在我的代码中的某个地方计算时间,然后获得通过的时间,以测量执行少量功能所花费的时间.我认为我使用的是timeit模块错误,但文档对我来说只是让人困惑.

import timeit

start = timeit.timeit()
print("hello")
end = timeit.timeit()
print(end - start)
Run Code Online (Sandbox Code Playgroud)

python performance timeit measure

1031
推荐指数
32
解决办法
116万
查看次数

Python:如何用常规属性替换属性?

基类有这个:

def _management_form(self):
    # code here
    return form
management_form = property(_management_form)
Run Code Online (Sandbox Code Playgroud)

在我的派生类中,我正在尝试写这个:

self.management_form = self.myfunc()
Run Code Online (Sandbox Code Playgroud)

但当然它不起作用.它告诉我"无法设置属性",因为该属性没有setter.但我不想设置它,我想重新定义"managent_form"的含义.我尝试del self.managent_form先放,但这也不起作用.那我该如何解决它的问题呢?

python properties

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

标签 统计

python ×2

measure ×1

performance ×1

properties ×1

timeit ×1