我正在使用API "我试着学更好的字典:
{'url': 'https://www.chess.com/live/game/8554438187', 'pgn': '[Event "Live Chess"]n[Site "Chess.com"]n[Date "2021.03.03"]n[Round "-"]n[White "AHMEDAHMED1984"]n[Black "pgmendormi"]n[Result "0-1"]
我需要url,所以我做了:
data = get_player_game_archives(username).json
url = data['archives'][-1]
games = requests.get(url).json()
game = games['games'][-1]
print(games['games'][-1]['url'])
但是我怎样才能得到"[Result "0-1"]"
我试着:
print(games['games'][-1]['url'][1])
但是它只给了我一个字符,我必须做一个循环吗?
和如何?
谢谢你的回答:)
games['games'][-1]['pgn'].splitlines()[-1]
应该能做到这一点