gpt4 book ai didi

dart - 如果两者都在消息后添加换行符,那么 dart 中的 print() 和 stdout.writeln() 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 02:44:43 26 4
gpt4 key购买 nike

这是我的简单 dart 代码。

import 'dart:io';

main(){
print("Hello World");
stdout.writeln("Another Hello World");
}

输出:

Hello World   //Prints newline by default. 
Another Hello World //Also print newline after this.

如果两个函数都在打印后打印一个换行符,那么它们有什么区别。

最佳答案

在 DartVM 上,行为是相同的。但是当 Dart 代码在浏览器中运行时,你不能使用 stdoutdart:io library不能在基于浏览器的应用程序中使用。 print作为核心库的一部分,它可以在任何地方使用。

一点不同(也在 VM 上)是 print can be overriden with Zone .

关于dart - 如果两者都在消息后添加换行符,那么 dart 中的 print() 和 stdout.writeln() 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52598211/

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