print('Имя:{0} Команда:{1} Здоровье:{2} Броня:{3} Оружие:{4}({5})'.format(w.name, w.team, w.health,
w.armor, w.weapon.name,w.weapon.damage))
print(
f'Имя:{w.name} '
f'Команда:{w.tem} '
f'Здоровье:{w.health}'
f'Броня:{w.armor}'
f'Оружие:{w.weapon.name}({w.weapon.damage})'
)
if ([False]*self.teamscount[ltlive])==[x.is_alive for x in self.teams[ltlive]])
if not any([x.is_alive for x in self.teams[ltlive]])
?>>> sum([x[0] for x in arrays])
34.33750876274861
>>> sum([x[1] for x in arrays])
19.305019168249604
>>> sum([x[2] for x in arrays])
32.17848566247153
>>> sum([x[3] for x in arrays])
22.424106744929986
...
import json
data = '''
[-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 15.626869483055735, 0.0]
[0.0, 19.305019168249604, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 22.424106744929986, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 24.802126691039216, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 25.41793956879349]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 32.17848566247153, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[34.33750876274861, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 38.54533200463435, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 40.605066388577725, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
'''
arrays = [json.loads(x) for x in data.split('\n') if x]
let arr = [
{city: 'Москва', address: 'адрес 1'},
{city: 'Москва', address: 'адрес 2'},
{city: 'Петербург', address: 'адрес 3'},
{city: 'Москва', address: 'адрес 4'},
]
[...new Set(arr.map(item => item.city))].map(function(item) {
return {city: item, address: arr.filter(itm => itm.city == item).map(itm => itm.address)}
})
def slugify(value, allow_unicode=False):
"""
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens.
Remove characters that aren't alphanumerics, underscores, or hyphens.
Convert to lowercase. Also strip leading and trailing whitespace.
"""
In [1]: unicodedata.normalize('NFKD', 'привет world')
Out[1]: 'привет world'
In [2]: 'привет world'.encode('ascii', 'ignore').decode('ascii')
Out[2]: ' world'
In [3]: my_string = 'привет world'.translate(
str.maketrans(
"абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ",
"abvgdeejzijklmnoprstufhzcss_y_euaABVGDEEJZIJKLMNOPRSTUFHZCSS_
...: Y_EUA"
))
In [4]: slugify(my_string)
Out[4]: 'privet-world'
import re
data = ['erwer', 'dd', '44j', '5.09', '33', 'dfgdfs', '99.100', '5645..99', '.434', '42342.']
[x for x in data if re.match('^\d+(\.\d){0,1}\d*$', x)]
['5.09', '33', '99.100']
def is_float(value):
try:
float(value)
except ValueError:
return False
return True
>>> is_float('65456')
True
>>> is_float('65456.00')
True
>>> is_float('65456.00gfghf')
False
from itertools import permutations
name = 'sasha'
surname = 'petrov'
birth_date = '11.01.1985' # тут еще желательно разбить по точке
nickname = 'sanek'
for j in range(3):
for im in permutations(birth_date.split('.'), j+1):
for x in permutations([name, surname, nickname, ''.join(im)], 2):
print(''.join(x))