自动生成真值表
truths的Python项目详细描述
真理是一个简单的工具,它能让你快速地产生真理 来自python变量名和短语的表
安装
pip install truths或git clone和pip 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 | +-------+-------+-------+-------+-----------+--------------+---------------------+
工作原理
看看密码!在幕后它把基地 对象上下文并为其生成值网格。那么, 短语在对象上下文中根据 值的网格