0
我已经创建了该程序,但面临一些错误。其显示包含从用户输入任何字母,但我想它应该在搜索词的所有字母的那些话: 我的代码是从单词表和打印单词中搜索字母
life=open('/Users/tim/Desktop/words.txt')
dds=str(input())
for list in life:
index=0
if dds[index] in list:
print(list)
index=index+1
我不得不这样做,因为我想它可以搜索哪些修改?
而且我想这:
life=open('/Users/tim/Desktop/words.txt')
dds="er"
for list in life:
index=0
if dds[index] in list:
print(list)
index=index+1
现在,我想它应该打印包含字的 “e”
你能解释一下你的答案吗? – user325923
你在做: '如果列表中的dds [index]:'这意味着它将打印所有在wordlist中的单词中包含任何字母“dds”的单词。 如果你试试这个: 'if dds [index:] in list:' 它会搜索wordlist中的所有字母。 [:]将选择所有的字母 –
感谢它的完美工作:) – user325923