【问题标题】:Write output from putStrLn to text file将 putStrLn 的输出写入文本文件
【发布时间】:2016-07-13 16:07:40
【问题描述】:

在 Haskell 中。有没有办法从 putStrln (ghc/ghci) 写入输出,例如:

putStrLn(printf $"this is a example string")

writeFile "example.txt" $ "[上面 putStrLn 的输出]"

【问题讨论】:

    标签: haskell io ghc


    【解决方案1】:

    当然,不要打电话给putStrLn

    writeFile "example.txt" $ printf $ "this is a example string"
    

    当然,对于这个例子,printf 一开始就不需要。

    writeFile "example.txt" "this is a example string"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 2013-08-30
      • 2013-03-20
      • 2014-06-11
      相关资源
      最近更新 更多