WTF!只需一行Python代码即可玩20几款小游戏
Posted Python小二
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WTF!只需一行Python代码即可玩20几款小游戏相关的知识,希望对你有一定的参考价值。
今天分享一个有趣的 github 项目:https://github.com/kingser/free-python-games
,通过该项目,我们只需一行代码即可玩 20 几款小游戏,下面具体来看一下。
安装
首先,我们进行安装,安装很简单,只需一行命令即可:pip install freegames
。
使用
安装完成之后,我们使用命令:python -m freegames list
查看一下可玩的游戏列表,如下所示:
ant
bagels
bounce
cannon
connect
crypto
fidget
flappy
guess
life
madlibs
maze
memory
minesweeper
pacman
paint
pong
simonsays
snake
tictactoe
tiles
tron
小游戏的运行(启动)使用命令:python -m freegames.游戏名
,下面通过示例具体看一下。
python -m freegames.snake
![](https://image.cha138.com/20220526/1a0d2424e6aa487b84f93f3e41d8e3c4.jpg)
python -m freegames.pacman
![](https://image.cha138.com/20220526/bdb8297b9d264d799416b0a4fe100930.jpg)
python -m freegames.flappy
![](https://image.cha138.com/20220526/ea1bf15d522d4fe291527d21be503e0b.jpg)
python -m freegames.connect
![](https://image.cha138.com/20220526/062d433a81794fb584500fa14ce6a3d4.jpg)
python -m freegames.cannon
![](https://image.cha138.com/20220526/68112f1f590e42c7b19791dda6de520c.jpg)
python -m freegames.memory
![](https://image.cha138.com/20220526/e5bbfdc6dbac409f97aeb7fa4f045207.jpg)
python -m freegames.pong
![](https://image.cha138.com/20220526/40aacc32d34b4d5c8ca9a27e38a5f1ad.jpg)
python -m freegames.simonsays
![](https://image.cha138.com/20220526/7a287f9fdb9a4986ba444324dbea19e4.jpg)
python -m freegames.tictactoe
![](https://image.cha138.com/20220526/1b81766bc0fd4294b665cab8b9aaf47c.jpg)
python -m freegames.tiles
![](https://image.cha138.com/20220526/b5963b1f3287425e9f7ce7da629a7c24.jpg)
python -m freegames.tron
![](https://image.cha138.com/20220526/8b7aac145a9e47f9a9daba3946192b3b.jpg)
python -m freegames.life
![](https://image.cha138.com/20220526/7035e161c7ec43a89a4baab4a204db3e.jpg)
python -m freegames.maze
![](https://image.cha138.com/20220526/b58834142e4b4a728720e46b8d409eca.jpg)
python -m freegames.fidget
![](https://image.cha138.com/20220526/977600bd010345869a0beb581259b279.jpg)
好了,这里就不一一列举了,有兴趣的小伙伴可以自己动手试试。
推荐阅读 点击标题可跳转
以上是关于WTF!只需一行Python代码即可玩20几款小游戏的主要内容,如果未能解决你的问题,请参考以下文章