print

将输出写入文件

with open('demo1.py', 'wt', encoding='utf8') as f:
    print('hello', file=f)

使用其他分隔符和换行符打印

print('ACME', 50, 91.5)
print('ACME', 50, 91.5, sep=',')
print('ACME', 50, 91.5, sep=',', end='!!
')
原文地址:https://www.cnblogs.com/wc89/p/12671805.html