自动生成真值表

truths的Python项目详细描述


真理是一个简单的工具,它能让你快速地产生真理 来自python变量名和短语的表

安装

pip install truthsgit clonepip install -e播放 使用代码

使用简单:

首先创建一些基本变量

importtruthsprinttruths.Truths(['a','b','x'])
+---+---+---+
| a | b | x |
+---+---+---+
| 0 | 0 | 0 |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| 1 | 1 | 1 |
+---+---+---+

添加一些短语

现在让我们使用这些基本变量并传入一些短语!你的基地 变量可以是任何您想要的,但必须是有效的python变量 名字。这些短语还必须是有效的python

fromtruthsimportTruthsprintTruths(['a','b','cat','has_address'],['(a and b)','a and b or cat','a and (b or cat) or has_address'])
+---+---+-----+-------------+-----------+----------------+---------------------------------+
| a | b | cat | has_address | (a and b) | a and b or cat | a and (b or cat) or has_address |
+---+---+-----+-------------+-----------+----------------+---------------------------------+
| 0 | 0 |  0  |      0      |     0     |       0        |                0                |
| 0 | 0 |  0  |      1      |     0     |       0        |                1                |
| 0 | 0 |  1  |      0      |     0     |       1        |                0                |
| 0 | 0 |  1  |      1      |     0     |       1        |                1                |
| 0 | 1 |  0  |      0      |     0     |       0        |                0                |
| 0 | 1 |  0  |      1      |     0     |       0        |                1                |
| 0 | 1 |  1  |      0      |     0     |       1        |                0                |
| 0 | 1 |  1  |      1      |     0     |       1        |                1                |
| 1 | 0 |  0  |      0      |     0     |       0        |                0                |
| 1 | 0 |  0  |      1      |     0     |       0        |                1                |
| 1 | 0 |  1  |      0      |     0     |       1        |                1                |
| 1 | 0 |  1  |      1      |     0     |       1        |                1                |
| 1 | 1 |  0  |      0      |     1     |       1        |                1                |
| 1 | 1 |  0  |      1      |     1     |       1        |                1                |
| 1 | 1 |  1  |      0      |     1     |       1        |                1                |
| 1 | 1 |  1  |      1      |     1     |       1        |                1                |
+---+---+-----+-------------+-----------+----------------+---------------------------------+

喜欢布尔词吗?

整洁啊?如果您喜欢真/假而不是数字传递ints=False

fromtruthsimportTruthsprintTruths(['a','b','x','d'],['(a and b)','a and b or x','a and (b or x) or d'],ints=False)
+-------+-------+-------+-------+-----------+--------------+---------------------+
|   a   |   b   |   x   |   d   | (a and b) | a and b or x | a and (b or x) or d |
+-------+-------+-------+-------+-----------+--------------+---------------------+
| False | False | False | False |   False   |    False     |        False        |
| False | False | False |  True |   False   |    False     |         True        |
| False | False |  True | False |   False   |     True     |        False        |
| False | False |  True |  True |   False   |     True     |         True        |
| False |  True | False | False |   False   |    False     |        False        |
| False |  True | False |  True |   False   |    False     |         True        |
| False |  True |  True | False |   False   |     True     |        False        |
| False |  True |  True |  True |   False   |     True     |         True        |
|  True | False | False | False |   False   |    False     |        False        |
|  True | False | False |  True |   False   |    False     |         True        |
|  True | False |  True | False |   False   |     True     |         True        |
|  True | False |  True |  True |   False   |     True     |         True        |
|  True |  True | False | False |    True   |     True     |         True        |
|  True |  True | False |  True |    True   |     True     |         True        |
|  True |  True |  True | False |    True   |     True     |         True        |
|  True |  True |  True |  True |    True   |     True     |         True        |
+-------+-------+-------+-------+-----------+--------------+---------------------+

工作原理

看看密码!在幕后它把基地 对象上下文并为其生成值网格。那么, 短语在对象上下文中根据 值的网格

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从应用程序中的环境变量构造URL。性质   java代码中的Android按钮背景图像   java方法_jspService(HttpServletRequest,HttpServletResponse)的代码超过了weblogic 12.2中的65535字节限制   在Android中创建xml文件时出现java错误   java更新AVL树问题   java初学者,使用导航抽屉切换时维护片段状态   java m2e仍然给出一个错误,称“生命周期配置未涵盖插件执行”,即使自定义插件中有显式绑定   java,swing;用于创建对象的简单gui   java有没有办法使用Gradle将Kotlin类编译成JavaScript?   java如何防止Spring应用程序上下文关闭,直到启动关闭挂钩   Java:在o(1)空间和o(n)时间中反转字符串   java如何使用comparator按值对TreeMap排序   PHP和Java Unix时间戳之间的差异   java Curl到rest-assured API   java如何在使用okhttp请求POST时避免获取captcha错误   java如何将媒体存储目录导出到操作视图中?   Tomcat找不到Java servlet的开发版本   在jsp中,生成pdf我得到一个java。lang.IllegalStateException:流   如果在RESTAPI调用中找不到数据库中的数据,将返回哪个HTTP状态代码