PhoneValue=0
if (condition== "new"):
PhoneValue=int(PhoneValue+10)
else:
PhoneValue=int(PhoneValue+9)
if GPS==bool(input("true")):
PhoneValue=int(PhoneValue+1)
else:
PhoneValue=int(PhoneValue)
if WiFi==eval(bool(input("true"))):
PhoneValue=int(PhoneValue+1)
else:
PhoneValue=int(PhoneValue)
if camera==eval(bool(input("true"))):
PhoneValue=int(PhoneValue+1)
else:
PhoneValue=int(PhoneValue)
global PhoneValue
这是我的代码。我应该能够输入条件,GPS,摄像头和WiFi,代码评估输入并为每个条件给出分数。如果手机是新的,它会得到10分,如果使用它,则获得9分。对于GPS,相机和WiFi,我希望使用布尔值来给它一个真正的点或没有点的假。我想知道如何将输入字符串转换为布尔值以便将其添加到电话值?在输入中使用蟒蛇中的布尔值