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/20220915/2f710410453440188c16d901119fcdf8.jpg)
python -m freegames.pacman
![](https://image.cha138.com/20220915/c2d5d7fc0e01424685dd4e7a270d259d.jpg)
python -m freegames.flappy
![](https://image.cha138.com/20220915/7490371bb8d44681b875b5ae11d2c78a.jpg)
python -m freegames.connect
![](https://image.cha138.com/20220915/bb6f485fe07346b9ab51dc224bad981e.jpg)
python -m freegames.cannon
![](https://image.cha138.com/20220915/15dfd3e4835441f887d2f84d7f21a082.jpg)
python -m freegames.memory
![](https://image.cha138.com/20220915/48b5e311622f466e9b5d2681868eca16.jpg)
python -m freegames.pong
![](https://image.cha138.com/20220915/30f55c9db303444eae2ef420609e71c5.jpg)
python -m freegames.simonsays
![](https://image.cha138.com/20220915/ef8802964689444e9f3555a2fecc6d3c.jpg)
python -m freegames.tictactoe
![](https://image.cha138.com/20220915/ecd0cf1c452c4abcaed6b20447a2f748.jpg)
python -m freegames.tiles
![](https://image.cha138.com/20220915/9aa77ffe68b6410986f9956dc5ac32c6.jpg)
python -m freegames.tron
![](https://image.cha138.com/20220915/0d7ffa83231542b3a4912e34dd205893.jpg)
python -m freegames.life
![](https://image.cha138.com/20220915/6a247a340f5f4617989c9e2abad29fc0.jpg)
python -m freegames.maze
![](https://image.cha138.com/20220915/fd07f1d1765b496fa8d2dfa21350e7ab.jpg)
python -m freegames.fidget
![](https://image.cha138.com/20220915/756b9e01637b4de897d7dbc267b41197.jpg)
好了,这里就不一一列举了,有兴趣的小伙伴可以自己动手试试。
推荐阅读 点击标题可跳转
以上是关于WTF!只需一行Python代码即可玩20几款小游戏的主要内容,如果未能解决你的问题,请参考以下文章