回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在做一种测验,想知道如何将结果与文本文件进行比较。通过提示输入回答问题后,函数将返回一个四位代码。我希望将四位数代码与我写出来的文本文件中的“truecode”进行比较,并提供以下附加信息:</p>
<pre><code>villagername,personality,birthday,zodiac,truecode,species
Ankha,snooty,September 22nd,Virgo,A420,Cat
Bangle,peppy,August 27th,Virgo,A330,Tiger
Bianca,peppy,December 13th,Sagittarius,A320,Tiger
Bob,lazy,January 1st,Capricorn,A210,Cat
Bud,jock,August 8th,Leo,A310,Lion
</code></pre>
<p>我想把其他信息打印出来</p>
<pre><code> print("Your villager is " + villagername)
print("They are a " + personality + " type villagers and of the " + species + " species.")
print("Their birthday is " + birthday + " and they are a " + zodiac)
print("I hope you enjoyed this quiz!")
</code></pre>
<p>我不知道如何提取这些信息,并将其与我所拥有的进行比较。我应该使用列表还是字典?我在谷歌上搜索我的问题时感到很沮丧,我想知道我是不是绕错了方向</p>
<p>我如何将四位代码(将从另一个函数返回)与“真代码”进行比较,并像上面那样把所有内容都吐出来</p>