Home > Net >  Process finished with exit code 0 python
Process finished with exit code 0 python

Time:11-16

I'm new to python. I have this code. 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". When I'm trying to print(get_settlement_postoffices()), it gives me the same answer.

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.

CodePudding user response:

You should create an instance of this class and call its method, like this:

myinstance = Services()
print(myinstance.get_settlement_postoffices())

The exit code of 0 means that the process has been executed and exited successfully.

CodePudding user response:

Are you creating an instance of that class, before calling the function? e.g

i = Services()
print(i.get_settlement_postoffices())

CodePudding user response:

Exit code 0 means that the program executed without errors and has run successfully.

You can try printing debug messages in your terminal, by putting print("This code works!") in your code at different points. This can help find if it is causing errors.

Hope this helped!

  • Related