繁体   English   中英

在Python中控制索引值

[英]Controlling index value in Python

这是我的代码:

from operator import index

import sympy
from sympy import symbols, Equivalent
from sympy.logic.boolalg import to_cnf as fnc, Implies, to_cnf
from sympy.abc import a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, v, w, x, y, z
import tkinter


def eq(a, b):
    return fnc(Equivalent(a, b), True)

inr = str(input('Enter formula: '))
x = ' '
for i in inr:
     #print(inr[inr.index(i-2)])
     if i == '>':
         i = '>>'
         x += i
     elif i == '=':

         print(i)
         i = 'Equivalent'
         x += i

     else:
         x += i

print(fnc(x, True))

因此,如果我输入=(a,b),则可以使用。 “ =”将调用函数Equivalent(a, b) ,该函数将返回公式的合取范式。 我想控制索引i分配值Equivalent而不是输入=(a,b)。 我将输入(a = b),因此将'='移至三个框=(a,b)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM