python - 列表中的字典。返回字典名称
问题描述
我正在使我的第一个项目成为井字游戏。我有以下内容:
the_board = {'1 3': ' ' , '2 3': ' ' , '3 3': ' ' ,
'1 2': ' ' , '2 2': ' ' , '3 2': ' ' ,
'1 1': ' ' , '2 1': ' ' , '3 1': ' ' }
wins = [[the_board['1 3'],the_board['2 3'],the_board['3 3']],
[the_board['1 2'],the_board['2 2'],the_board['3 2']],
[the_board['1 1'],the_board['2 1'],the_board['3 1']],
[the_board['1 3'],the_board['1 2'],the_board['1 1']],
[the_board['2 3'],the_board['2 2'],the_board['2 1']],
[the_board['3 3'],the_board['3 2'],the_board['3 1']],
[the_board['1 3'],the_board['2 2'],the_board['3 1']],
[the_board['1 1'],the_board['2 2'],the_board['3 3']]]
有什么方法可以在我输入wins[0][0]
时打印出来"the_board['1 3']"
吗?然后我可以分配一个"X"
tothe_board['1 3']
吗?
谢谢
解决方案
推荐阅读
- node.js - 猫鼬模式包含整个数据库对象而不是定义的模式对象
- docker - 如何使用 traefik 在 docker compose 中代理到后端
- javascript - Tabulator.js 停止初始 ajax 数据加载并在第一次过滤后加载数据
- c# - Modifying a JSON file using System.Text.Json
- javascript - 使用 WebGL 在画布上绘图后,HtmlCanvasElement toDataURL 似乎不起作用
- selenium - selenium.JavascriptException:javascript 错误:无法在“文档”上执行“elementFromPoint”:提供的双精度值是非有限的
- r - Create ranges by accumulating values
- postgresql - select all rows where array elements exist
- android - WorkManager PeriodicWorkRequest run twice
- json - 使用 JSON API 到 Powershell 的过滤器选项 - 当前使用 Invoke-Restmethd