我们的目标是将print输出导入txt,实现方法如下:
log = open("a.txt",mode="a",encoding="utf-8") for i in range(100): a=b() print(a,file = log) log.close()