【问题标题】:i want to save the result of the'for-loop' as text file in python我想将'for-loop'的结果保存为python中的文本文件
【发布时间】:2017-10-23 04:31:22
【问题描述】:

我使用了 for 循环。 我想将'for-loop'的结果保存为文本文件。我该怎么办?

enter image description here

【问题讨论】:

标签: python for-loop save text-files


【解决方案1】:

把最后一行改成

print(how_can_i_do[h*a:h*(a+1)], file=f, end='\n')

循环后,你还必须关闭所有文件流。

【讨论】:

    猜你喜欢
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多