コード例 #1
0
 def get_currency(cls, currency_name):
     try:
         with request.urlopen(cls.Constants.base_url +
                              currency_name) as response:
             data = response.read().decode()
             json_data = json.loads(data)
             return Currency(json_data)
     except Exception as error:
         return None
コード例 #2
0
    def get_currency(cls, initial_currency_name, final_currency_name):
        try:
            with request.urlopen(cls.Constants.base_url + initial_currency_name) as response:
                data = response.read().decode()
                json_data = json.loads(data)
                return Currency(final_currency_name, json_data)

        except URLError:
            return None
コード例 #3
0
 def get_currency(cls, currency_name):
     try:
         with request.urlopen(cls.Constants.base_url +
                              currency_name) as response:
             data = response.read().decode()
             data_dictionary = json.loads(data)
             return Currency(data_dictionary)
     except Exception:
         print(
             'The calculator is not going to work, invalid URL inserted or non-available currency.'
         )
コード例 #4
0
ファイル: main.py プロジェクト: SebastianPEZROE/TP-2018-1
 def run(self):
     self.__currency = Currency("USD", 18.90)
     self.__master.mainloop()