【发布时间】:2021-07-01 10:50:18
【问题描述】:
我运行了一个产生以下消息的函数:
[Output truncated]No imagary was found at location 13.51418,100.525398094512No imagary was found at location 13.5142126237624,100.519283133217No imagary was found at location 13.5142452475248,100.667925324763No imagary was found at location 13.5142778712871,100.633407407186No imagary was found at location 13.5143104950495,100.615685968347No imagary was found at location 13.5143431188119,100.438773863735No imagary was found at location 13.5143757425743,100.584423279119No imagary was found at location 13.5144083663366,100.518027443291No imagary was found at location 13.514440990099,100.675459782113No imagary was found at location 13.5144736138614,100.667897127582No imagary was found at location 13.5145062376238,100.632888261162No imagary was found at location 13.5145388613861,100.627567350767No imagary was found at location 13.5145714851485,100.495578874954trying URL 'https://maps.googleapis.com/maps/api/streetview?&location=13.5146041089109,100.687791167767&size=8000x5333&heading=0&fov=90&pitch=0&
但是,当我运行sink() 和我的函数(此处省略详细信息)时,my_output.txt 文件没有保存上面的控制台输出。有谁知道如何解决这个问题以便保存警告和消息?
代码:
sink(file = 'my_output.txt')
MyFunction(...)
sink()
注意:我查看过类似的查询,例如 How to capture warnings with the console output?,但怀疑有更简单的解决方案?
【问题讨论】:
-
@GKi 谢谢,但这个解决方案也不起作用。它只保存打印消息而不是警告。
-
在我的情况下它正在工作 - 请参阅下面的答案。