gpt4 book ai didi

python - 将段落写入文件

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:58 24 4
gpt4 key购买 nike

好吧,这很简单,我想将一大段文本写入文件。我知道我能做到

f=open("blah.txt",'w')
f.write("blah blah \n")
f.write("bla blah blah ")
f.close()

但是什么是更优雅的解决方案呢?

最佳答案

f.write("""I’ve got a lovely bunch of coconuts
There they are all standing in a row
Big ones, small ones, some as big as your head
Give them a twist a flick of the wrist
That’s what the showman said""")

关于python - 将段落写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5226862/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com