【发布时间】:2014-02-15 17:21:02
【问题描述】:
由于某种原因,这段脚本返回错误:“TypeError: string indices must be integers”;我看不出有什么问题。我是不是很愚蠢并且在这里忽略了一个明显的错误?我一辈子都见不到!
terms = {"ALU":"Arithmetic Logic Unit"}
term = input("Type in a term you wish to see: ")
if term in terms:
definition = term[terms]
sentence = term + " - " + definition
print(sentence)
else:
print("Term doesn't exist.")
【问题讨论】:
-
天哪,我是不是觉得自己很蠢!感谢大家为我指明正确的方向。