我正在为学校项目创建一些代码,对于我稍后使用的模块,我需要知道结束的强度(end_intensity)是什么。运行代码时,end_intensity仍然是未分配的,这意味着
if client_intensity == "High":
行永远不会被运行。有人可以解释为什么它不会分配。
correct = False
end_intensity = "Unassigned"
while correct != True:
id_search = input("please enter the Client ID of the client you wish to record results for:")
# open file, with will automatically close it for you
with open("text_documents/clientIntensity.txt") as f:
user_found = False
# loop over every line
for line in f:
client,intensity = line.split(",")
if id_search == client:
correct = True
user_found = True
intensity = str (intensity)
client_intensity = intensity
#assigns which one is the end intensity
if intensity == 'High':
end_intensity = 'Moderate'
elif intensity == 'Moderate':
end_intensity = 'High'
if user_found == False:
print("I'm sorry no results we're found for that ID, please try again\n")
print(end_intensity)
文本文件采用以下格式:
(我为文本文档格式的数字道歉,堆栈溢出只会让我这样显示)
任何帮助将不胜感激,谢谢
Ieuan