English 中文(简体)
误差:功能()理由代码必须是代码,而不是体质。
原标题:TypeError: function() argument code must be code, not str
  • 时间:2022-06-19 10:40:04
  •  标签:
  • python

误差:功能()理由代码必须是代码,而不是体质。

我的主要档案

with open("city.txt","r") as f:
    d2 = f.read()
d2=d2.strip()
if len(d2)!=0 or len(d2)!=1:
    m=d2

else:
    m="new york"
import asyncio
import python_weather
async def getweather():
    client = python_weather.Client(format=python_weather.IMPERIAL)
    weather = await client.find(m)
    for forecast in weather.forecasts:      
        with open("wx1.txt","a+") as f:
            f.write(str(str(forecast.date)+" "+ str(forecast.sky_text))
    await client.close()

这是错误的全部标志。

06-19 15:59:58.408  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/app/main.py", line 74, in <module>
06-19 15:59:58.410  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/python_weather/__init__.py", line 28, in <module>
06-19 15:59:58.411  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/python_weather/client.py", line 1, in <module>
06-19 15:59:58.412  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/python_weather/rest.py", line 3, in <module>
06-19 15:59:58.420  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/aiohttp/__init__.py", line 6, in <module>
06-19 15:59:58.421  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/aiohttp/client.py", line 32, in <module>
06-19 15:59:58.422  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/aiohttp/http.py", line 7, in <module>
06-19 15:59:58.423  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/aiohttp/http_parser.py", line 15, in <module>
06-19 15:59:58.424  6609  6645 I python  :    File "/mnt/d/girlchat1/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Olivia/armeabi-v7a/aiohttp/helpers.py", line 607, in <module>

根据这一说法,帮助者有错误。 页: 1 第607和以下是同一部法典。

class CeilTimeout(async_timeout.timeout):


    def __call__(self) -> async_timeout.timeout:
        if self._timeout is not None:
            self._task = current_task(loop=self._loop)
            if self._task is None:
                raise RuntimeError(
                     Timeout context manager should be used inside a task )
            self._cancel_handler = self._loop.call_at(
                ceil(self._loop.time() + self._timeout), self._cancel_task)
        return self

页: 1 Don 了解造成什么问题,但任何帮助都是巨大的。

问题回答

我也有这一错误,并在此领导。 错误的原因不同,因此,我在此包括这一答案。

I have a decorator, in it i expect to receive a class/func. However, when decorating both a base class, and another class that inherits from the base class, I came across this error.

@deprecated("This class is deprecated. Please use NewClass instead.")
class OldClass:
    def __init__(self):
        print("Initializing an instance of OldClass.")

@deprecated("This subclass is deprecated. Please use NewSubClass instead.")
class SubClass(OldClass):
    def __init__(self):
        super().__init__()

TypeError: function() argument  code  must be code, not str

类型错误是由于我的校正员预计会有一个班级/unc,实际上会接收一个校正员。 固定装置是处理提供一名矫正员的情况,并取得其校正的等级/单位。

任何人,如果只是想方说这个问题的主题线上的具体错误...... 这种错误是在试图将某类物品分类时发生的。 很容易用“因素”功能来犯这一错误,特别是使用上CamelCase的名称。

例如,您可以选择<代码>tempfile.NamedT InterimFile为一类。 (至少我这样做了) 但事实上:

>>> type(NamedTemporaryFile)
<class  function >

So this happens:

>>> class TheSubclass(NamedTemporaryFile): pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function() argument  code  must be code, not str

功能回报通常的物体的实际类型是你想要分级的(即使有你可以做的灵活方法)。 因此,它更能做一些事情,例如从头开始创造自己的总结,或只是采取完全不同的做法,而不是试图制造一个阶级。

如果你利用第三方图书馆来做到这一点,如果它不与图书馆本身讨论一个问题(如这里的其他答复之一),那么你可以不正确地重新使用图书馆。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签