jjzjj

Callable

全部标签

python - 类型错误 : 'list' object is not callable in python

我是Python新手,正在学习教程。教程中有一个list的例子:example=list('easyhoss')现在,在教程中,example=['e','a',...,'s']。但就我而言,我收到以下错误:>>>example=list('easyhoss')Traceback(mostrecentcalllast):File"",line1,inTypeError:'list'objectisnotcallable请告诉我哪里错了。我搜索了SOthis但不一样。 最佳答案 好像你有shadowed内置名称list,它指向一个类,

python - 类型错误 : 'list' object is not callable in python

我是Python新手,正在学习教程。教程中有一个list的例子:example=list('easyhoss')现在,在教程中,example=['e','a',...,'s']。但就我而言,我收到以下错误:>>>example=list('easyhoss')Traceback(mostrecentcalllast):File"",line1,inTypeError:'list'objectisnotcallable请告诉我哪里错了。我搜索了SOthis但不一样。 最佳答案 好像你有shadowed内置名称list,它指向一个类,

python - 类型错误 : 'int' object is not callable

给定以下整数和计算from__future__importdivisiona=23b=45c=16round((a/b)*0.9*c)这会导致:TypeError:'int'objectisnotcallable.如何将输出四舍五入为整数? 最佳答案 在你的代码的其他地方你有类似这样的东西:round=42那么当你写的时候round((a/b)*0.9*c)这被解释为意味着对绑定(bind)到round的对象的函数调用,这是一个int。这失败了。问题是任何代码将int绑定(bind)到名称round。找到并删除它。

python - 类型错误 : 'int' object is not callable

给定以下整数和计算from__future__importdivisiona=23b=45c=16round((a/b)*0.9*c)这会导致:TypeError:'int'objectisnotcallable.如何将输出四舍五入为整数? 最佳答案 在你的代码的其他地方你有类似这样的东西:round=42那么当你写的时候round((a/b)*0.9*c)这被解释为意味着对绑定(bind)到round的对象的函数调用,这是一个int。这失败了。问题是任何代码将int绑定(bind)到名称round。找到并删除它。

python - 为什么像 `str = str(...)` 这样的代码会导致 TypeError,但只是第二次?

我有一些类似的代码:defexample(parameter):globalstrstr=str(parameter)print(str)example(1)example(2)第一次调用example有效,但第二次我收到如下错误:Traceback(mostrecentcalllast):File"test.py",line7,inexample(2)File"test.py",line3,inexamplestr=str(parameter)TypeError:'str'objectisnotcallable为什么会发生这种情况,我该如何解决?如果您在交互式session中遇到了这

python - 为什么像 `str = str(...)` 这样的代码会导致 TypeError,但只是第二次?

我有一些类似的代码:defexample(parameter):globalstrstr=str(parameter)print(str)example(1)example(2)第一次调用example有效,但第二次我收到如下错误:Traceback(mostrecentcalllast):File"test.py",line7,inexample(2)File"test.py",line3,inexamplestr=str(parameter)TypeError:'str'objectisnotcallable为什么会发生这种情况,我该如何解决?如果您在交互式session中遇到了这

python - Django URL 类型错误 : view must be a callable or a list/tuple in the case of include()

升级到Django1.10后,出现错误:TypeError:viewmustbeacallableoralist/tupleinthecaseofinclude().我的urls.py如下:fromdjango.conf.urlsimportinclude,urlurlpatterns=[url(r'^$','myapp.views.home'),url(r'^contact/$','myapp.views.contact'),url(r'^login/$','django.contrib.auth.views.login'),]完整的回溯是:Traceback(mostrecentc

python - Django URL 类型错误 : view must be a callable or a list/tuple in the case of include()

升级到Django1.10后,出现错误:TypeError:viewmustbeacallableoralist/tupleinthecaseofinclude().我的urls.py如下:fromdjango.conf.urlsimportinclude,urlurlpatterns=[url(r'^$','myapp.views.home'),url(r'^contact/$','myapp.views.contact'),url(r'^login/$','django.contrib.auth.views.login'),]完整的回溯是:Traceback(mostrecentc

java - CompletableFuture supplyAsync

我刚刚开始探索Java8的一些并发特性。让我有点困惑的一件事是这两个静态方法:CompletableFuturerunAsync(Runnablerunnable)CompletableFuturesupplyAsync(Suppliersupplier)有谁知道他们为什么选择使用接口(interface)供应商?使用Callable是不是更自然,类比Runnable返回值?那是因为供应商没有抛出无法处理的异常吗? 最佳答案 简答不,使用Callable不是更自然而不是Supplier在CompletableFuture.suppl

java - CompletableFuture supplyAsync

我刚刚开始探索Java8的一些并发特性。让我有点困惑的一件事是这两个静态方法:CompletableFuturerunAsync(Runnablerunnable)CompletableFuturesupplyAsync(Suppliersupplier)有谁知道他们为什么选择使用接口(interface)供应商?使用Callable是不是更自然,类比Runnable返回值?那是因为供应商没有抛出无法处理的异常吗? 最佳答案 简答不,使用Callable不是更自然而不是Supplier在CompletableFuture.suppl