gpt4 book ai didi

powershell - 当管道整数数组时 $_ 变量为空?

转载 作者:行者123 更新时间:2023-12-02 20:24:03 25 4
gpt4 key购买 nike

以此为例:

$var = "one","two","three"
0..2 | select-object $var[$_]

Index operation failed; the array index evaluated to null.
At line:1 char:27
+ 0..2 | select-object $var[ <<<< $_]
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArrayIndex

为什么 $_ 为空?

最佳答案

我不明白你为什么使用 select-object

试试这个:

$var = "one","two","three"
0..2 | % { $var[$_]}

关于powershell - 当管道整数数组时 $_ 变量为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7684250/

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