所以我试图将X从test()传递给rfid()进行测试,它不会工作:
这就是我所拥有的:
def test(x):
testcard = 8974
x=testcard
return x
def rfid():
#This will just see if the rfid chip has enough digits
main= 8974
# This looks to see if the rfid chip has enough digits to pass the test
if main == x:
print ("Card read check complete")
cardlength= info[main + readlen]
main += readlen + 1
return True,info[main:main + cardlength]
else:
main += readlen + 1
return False,0,''
def main():
rfid(x)
main()
答案 0 :(得分:1)
首先,你必须解决这个问题:
def rfid(x):
# ... rest of code
你看,如果一个函数需要一个参数,它必须被声明为这样。接下来,您必须从rfid()
实际调用 test()
:
def test():
x = 8974
return rfid(x)
在main()
中,请致电test()
。或者只需致电test()
,就无需声明并致电main()
:
def main():
test()
main()