我认为问题是我需要结合str和int所以我使用"(str(myvariable))并且括号将它抛弃。不过,我对此并不确定。这是代码:
#Save
if "ave" in animal: #- the s because of the .strip("s") on line 9
with open(timeStamped('AnimalCount.txt'),'w') as outf:
outf.write('Pronghorn: ' + (str(pronghorn)) \n 'Deer: ' + (str(deer)))
print " "
print "Saved"
print " "
问题出在第4行。谢谢!
答案 0 :(得分:1)
您需要新行字符在引号内:
'Pronghorn: ' + (str(pronghorn)) + '\n Deer: ' + (str(deer))