你想将 print() 函数的输出重定向到一个文件中去。
print()
with open('d:/work/test.txt', 'wt') as f: print('Hello World!', file=f)
Last updated 5 years ago
Was this helpful?