gpt4 book ai didi

powershell - 如何在 PowerShell 中换行?

转载 作者:行者123 更新时间:2023-12-03 05:23:57 25 4
gpt4 key购买 nike

我 [对 PowerShell 完全陌生,] 在循环中连接字符串,如果发生特殊情况,我应该插入换行符...我该怎么做?

基本上寻找与 \n 等效的内容。

$str = ""
foreach($line in $file){
if($line -Match $review){ #Special condition
$str += ANSWER #looking for ANSWER
}
#code.....
}

到目前为止我已经尝试过

"\n" '\n' "\N" '\N' "\r" '\r' "\R" '\R' '`n' '`r' '-n' '-r' 

最佳答案

尝试使用双引号"`n"。 (不是单引号 '`n' )

有关转义字符的完整列表,请参阅:

有关_Escape_character的帮助

代码应该是

$str += "`n"

关于powershell - 如何在 PowerShell 中换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11876901/

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