WTF!只需一行 Python 代码即可玩 20 几款小游戏
Posted AI科技大本营
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WTF!只需一行 Python 代码即可玩 20 几款小游戏相关的知识,希望对你有一定的参考价值。
作者 | Python小二
来源 | Python小二
今天分享一个有趣的 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/20220530/74a6dc269170452192f9f802c1667ab5.jpg)
python -m freegames.pacman
![](https://image.cha138.com/20220530/2daf4733b1ea4869ad60e7f03c65cf13.jpg)
python -m freegames.flappy
![](https://image.cha138.com/20220530/2bd02082127b406291239655a8e46536.jpg)
python -m freegames.connect
![](https://image.cha138.com/20220530/83ed455e42564e0ca4228bb77266d8a6.jpg)
python -m freegames.cannon
![](https://image.cha138.com/20220530/529072cec2544a51945403a98544b24a.jpg)
python -m freegames.memory
![](https://image.cha138.com/20220530/ea9ea5f0d4974fe593b87272c1dc27c9.jpg)
python -m freegames.pong
![](https://image.cha138.com/20220530/2c28c5a85f44468d98bf471b129821a6.jpg)
python -m freegames.simonsays
![](https://image.cha138.com/20220530/295282fc345641f6a727d5c232a6e5d0.jpg)
python -m freegames.tictactoe
![](https://image.cha138.com/20220530/ca3c98a636ba4c2eb19f8de9fb8442c4.jpg)
python -m freegames.tiles
![](https://image.cha138.com/20220530/309fb268d3d84d9e86828aee411871db.jpg)
python -m freegames.tron
![](https://image.cha138.com/20220530/cfa359f077494396b4221fb38c545ae1.jpg)
python -m freegames.life
![](https://image.cha138.com/20220530/9cb72c31f3b7408d945ffc7953dde6e8.jpg)
python -m freegames.maze
![](https://image.cha138.com/20220530/f05d640429f84b8d8c617af9ec8a3760.jpg)
python -m freegames.fidget
![](https://image.cha138.com/20220530/aa8b6069311a4c8dbd4a154277e666d5.jpg)
好了,这里就不一一列举了,有兴趣的小伙伴可以自己动手试试。
该视频号动态不可引用
往期回顾
分享
点收藏
点点赞
点在看
以上是关于WTF!只需一行 Python 代码即可玩 20 几款小游戏的主要内容,如果未能解决你的问题,请参考以下文章