[英]Process finished with exit code 0 python
I'm new to python. I have this code.我是 python 的新用户。我有这个代码。 I need to get a result as a json from postoffices, but it only tells that I don't have problems in my code like "Process finished with exit code 0".我需要从邮局获得 json 的结果,但它只说明我的代码没有问题,例如“进程已完成,退出代码为 0”。 When I'm trying to print(get_settlement_postoffices())
, it gives me the same answer.当我尝试print(get_settlement_postoffices())
时,它给了我相同的答案。
from __future__ import annotations
from datetime import datetime
import json
from typing import TYPE_CHECKING, List, Optional, Union
from pochta.enums import PostofficeWorkType
from pochta.utils import HTTPMethod
class Services:
def get_settlement_postoffices(self, settlement: str,
region: Optional[str] = None,
district: Optional[str] = None) -> List[str]:
url = '/postoffice/1.0/settlement.offices.codes'
params = {
'settlement': settlement,
'region': region,
'district': district,
}
res = self._client.request(HTTPMethod.GET, url, params=params)
return res.json()
I want to get an array with postal codes of a city I've chosen in a settlement param.我想获得一个数组,其中包含我在结算参数中选择的城市的邮政编码。
You should create an instance of this class and call its method, like this:您应该创建此 class 的实例并调用其方法,如下所示:
myinstance = Services()
print(myinstance.get_settlement_postoffices())
The exit code of 0 means that the process has been executed and exited successfully. exit code为0表示进程已经执行成功退出。
Are you creating an instance of that class, before calling the function?在调用 function 之前,您是否正在创建该 class 的实例? eg例如
i = Services()
print(i.get_settlement_postoffices())
Exit code 0 means that the program executed without errors and has run successfully.退出代码 0 表示程序执行无误并成功运行。
You can try printing debug messages in your terminal, by putting print("This code works!")
in your code at different points.您可以尝试在终端中打印调试消息,方法是在代码的不同位置放置print("This code works!")
。 This can help find if it is causing errors.这有助于确定它是否导致了错误。
Hope this helped!希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.