1;
1, 2;
1; 2;
A ? B : C
, где А,B,C - какие-то выражения. Так что можно записывать вместо if-else с отбрасыванием значения:x > 5 ? x-- : x++
func WriteJson(d structs.Bassketball) error {
f, err := os.OpenFile("basketball.json", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer f.Close()
rawJSON, _ := json.Marshal(d)
_, err = f.Write(rawJSON)
if err != nil {
return err
}
return nil
}
type Forks []struct {
ForkID string `json:"fork_id"`
Income float64 `json:"income"`
Sport string `json:"sport"`
...............
AliveSec int `json:"alive_sec"`
ValuingData ValuingData `json:"valuing_data"`
}
type Fork struct {
ForkID string `json:"fork_id"`
Income float64 `json:"income"`
Sport string `json:"sport"`
...............
AliveSec int `json:"alive_sec"`
ValuingData ValuingData `json:"valuing_data"`
}
type Forks []Fork
func checkBet(body []byte, v *Fork) {
......
task_0 = asyncio.create_task(get_request(session, url))
response = await task_0
task_1 = asyncio.create_task(parse_json(response))
await asyncio.gather(task_0, task_1)
async def handle_request(session, url):
async with session.get(url) as response:
data = await response.json()
results = []
for outcomes in data:
results.append(
(outcomes["payload"]["id"],
outcomes["payload"]["name"],)
)
return results
session = ...
urls = [ .................. ]
tasks = [handle_request(session, url) for url in urls] #набор невыполненных асинхронных задач
# планируем их выполнение "одновременно"
all_results = asyncio.gather(*tasks) #почитай про return_exceptions
for results in all_results:
pass #тут уже работаешь с возвращённым значением
driver = creat_chrome()
driver.get(url)
WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.ID, "DisplayNewsDetails_main_div")))
innerHTML = driver.execute_script("return document.documentElement.outerHTML")
innerHTML = driver.execute_script("return document.documentElement.outerHTML")
сайте потом дает тебе HTML :=
который объявляет локальные переменные input и error. А та, которую вы объявили выше тут не используется.temp_data = defaultdict(list)
for data in odds:
temp_data[data['Team']].append((data['Odds'], data['Date']))
temp_data = {key: zip(*value) for key, value in temp_data.items()}
new_data = [dict(Team=team, Odds=odds, Date=date) for team, (odds, date) in temp_data.items()]
_teams = set([x['team'].strip() for x in teams])
for team in _teams:
_odds = [x['odds'] for x in filter(lambda x: x['team'] == team, odds)]
print(team, _odds)
import json
s = r'["pinnacle","update_markets","PINTN97C6CD59FD7","9122741,0",[["TOTALS__OVER(22.5)",0,"1.806","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"over\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"],["TOTALS__UNDER(22.5)",0,"2.02","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"under\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"]'
data = json.loads(s+']]')
print(data[4][0][0])
print(data[4][0][2])
TOTALS__OVER(22.5)
1.806
import json
s = r'["pinnacle","update_markets","PINTN97C6CD59FD7","9122741,0",[["TOTALS__OVER(22.5)",0,"1.806","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"over\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"],["TOTALS__UNDER(22.5)",0,"2.02","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"under\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"]'
data = json.loads(s+']]')
# print(data[4][0][0])
# print(data[4][0][2])
for x in data[4]:
print(x[0] +' - '+ x[2])
TOTALS__OVER(22.5) - 1.806
TOTALS__UNDER(22.5) - 2.02