python - 为什么我不能将两个变量附加为元组
问题描述
list = []
tuples = ((0,1),(1,1),(2,2),)
x = 0
y = 2
list.append([[], tuples + (x,y)])
print(list)
我使用此代码作为井字游戏 AI 的一部分来构造一棵树,但是当将此新列表附加到主列表时,元组值读取为 ((0,1),(1,1),(2,2), 0,2)。我打算将 x 和 y 变量作为单个元组的一部分,如下所示:((0,1),(1,1),(2,2),(0,2)) 我在这里做错了什么? 先感谢您
解决方案
list = []
tuples = ((0,1),(1,1),(2,2),)
x = 0
y = 2
list.append([[], tuples + ((x,y),)])
print(list)
推荐阅读
- oop - 带有材料清单的课程:最佳实践
- list - 返回列表的第 n 个元素
- reactjs - React 路由器是正确的,但不能按预期工作
- cygwin - 兼容性层与虚拟化层
- r - 数据表 lapply 和输出中的附加列
- python - 来自谷歌的 400 错误请求
- java - Vert.x:一个 ChainAuthHandler 中的多个 JWTAuthHandler
- jhipster - jHipster 显示“发生错误 :-(” 在 Internet Explorer 中打开应用程序时,但在 chrome 浏览器中工作正常
- java - 如何指定该用户是否已共享我的应用 x 次?
- lua - Kong v1.0.2 的自定义插件已启用但未安装