예제 #1
0
def fetch_hubble_launch(id_image, folder='./'):
    response = requests.get(f'http://hubblesite.org/api/v3/image/{id_image}')
    response.raise_for_status()
    extra_file = response.json()['image_files'][-1]
    url = f"https:{extra_file['file_url']}"
    path_file = f'{folder}/{id_image}{get_file_extension(url)}'
    load_image(url, path_file)
예제 #2
0
 def __init__(self, pos):
     # ранги
     self.ranks = "23456789tjqka"
     # масти
     self.suits = "dchs"
     # генератор списков создающий колоду из 52 карт
     self.cards = [Card(r, s) for r in self.ranks for s in self.suits]
     # перетасовываем колоду. Не забудьте импортировать функцию shuffle из модуля random
     self.image = load_image('Images/cards', 'back.png', 1)
     self.pos = pos
     shuffle(self.cards)
예제 #3
0
 def __init__(self, rank, suit):
     # Задавать масти буквами - c, d, h, s
     self.rank = rank  # Ранг карты(Туз, король и т.д.)
     self.suit = suit  # Масть карты (черви, пики и т.д.)
     self.image = load_image(path=os.path.join('Images', 'cards'), name='{}{}.png'.format(suit, rank))
예제 #4
0
 def __init__(self, pos, value, number):
     self.image = load_image(path=os.path.join('Images', 'chips'), name='chip{}.png'.format(value))
     self.pos = pos
     self.number = number
     self.value = value
예제 #5
0
def fetch_spacex_last_launch(folder='./'):
    response = requests.get('https://api.spacexdata.com/v4/launches/latest')
    response.raise_for_status()
    images = response.json()['links']['flickr']['original']
    for i, url in enumerate(images, start=1):
        load_image(url, f'{folder}/spacex{i}.jpg')