Beispiel #1
0
from id import Id
from friends import Friends

name = input('Имя пользователя: ')
client = Id(name)
uid = client.execute()

friends_client = Friends(uid)
friends = friends_client.execute()

for (age, count) in friends:
    print('{} {}'.format(int(age), '#' * count))
Beispiel #2
0
from datetime import datetime, date
from user_id import UserId
from friends import Friends
from random import randint, normalvariate

import matplotlib.pyplot as plt

if __name__ == "__main__":
    ages_dct = dict()
    get_user_id = UserId(input())
    get_friends = Friends(get_user_id.execute())
    it_dict = get_friends.execute()
    for f in it_dict:

        if f.get('bdate') is None:
            continue

        bdate = f['bdate'].split('.')
        if len(bdate) != 3:
            continue

        age = datetime.now(tz=None).date() - date(int(bdate[2]), int(bdate[1]),
                                                  int(bdate[0]))
        age = int(age.days / 365)

        if ages_dct.get(age) is None:
            ages_dct[age] = 1
        else:
            ages_dct[age] += 1

    x_axis = []