“@@quot”是什么符号在powershell中做?
我已经看到@
PowerShell中使用的符号用于初始数组。
@
符号究竟是什么表示的,我在哪里可以阅读有关它的更多信息?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我已经看到@
PowerShell中使用的符号用于初始数组。
@
符号究竟是什么表示的,我在哪里可以阅读有关它的更多信息?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
有用的 - 即使是较晚的问题 - 提供完整的答案,才能:
虽然上述答案提供了答案的最多,但它是 参见 about_arrays )
迫使该值是一个数组
$ a = @(ps | whene -like'foo')
hash Initializer (请参阅 about_hash_tables )
初始化带有键值对的哈希表,例如
$ hasharguments = @{path =“ test.txt”; destination =“ test2.txt”; whatif = $ true}
splatting (请参阅 about_splatting )
让我们调用一个带有数组或哈希桌子的参数的cmdlet,而不是更习惯的单独枚举参数,例如,使用上面的哈希表,
copy> copy> copy-item @hasharguments
(请参阅 about_quoting_rules )
让您使用易于嵌入式的引号,通常用来创建字符串,通常使用多行字符串,例如:
因为这种类型的问题('x'符号在powershell中意味着什么?)在stackoverflow上如此普遍,在许多读者的评论中,我都放在一个词典上。 PowerShell标点符号,刚刚在Simple-Talk.com上出版。阅读有关 @以及%和#和$ _的所有信息?以及 PowerShell Punctuation 的完整指南。该文章附带的是该壁画,它为您提供了一张纸上的所有内容:

While the above responses provide most of the answer it is useful--even this late to the question--to provide the full answer, to wit:
Array sub-expression (see about_arrays)
Forces the value to be an array, even if a singleton or a null, e.g.
$a = @(ps | where name -like 'foo')
Hash initializer (see about_hash_tables)
Initializes a hash table with key-value pairs, e.g.
$HashArguments = @{ Path = "test.txt"; Destination = "test2.txt"; WhatIf = $true }
Splatting (see about_splatting)
Let's you invoke a cmdlet with parameters from an array or a hash-table rather than the more customary individually enumerated parameters, e.g. using the hash table just above,
Copy-Item @HashArguments
Here strings (see about_quoting_rules)
Let's you create strings with easily embedded quotes, typically used for multi-line strings, e.g.:
Because this type of question (what does 'x' notation mean in PowerShell?) is so common here on StackOverflow as well as in many reader comments, I put together a lexicon of PowerShell punctuation, just published on Simple-Talk.com. Read all about @ as well as % and # and $_ and ? and more at The Complete Guide to PowerShell Punctuation. Attached to the article is this wallchart that gives you everything on a single sheet:

PowerShell实际上将把任何逗号分隔的列表视为一个数组:
因此,在这些情况下, @是可选的。但是,对于关联阵列, @是必需的:
正式, @是“数组操作员”。您可以在与PowerShell一起安装的文档中阅读有关它的更多信息,或者我共同撰写的“ Windows PowerShell:TFM”之类的书。
PowerShell will actually treat any comma-separated list as an array:
So the @ is optional in those cases. However, for associative arrays, the @ is required:
Officially, @ is the "array operator." You can read more about it in the documentation that installed along with PowerShell, or in a book like "Windows PowerShell: TFM," which I co-authored.
您还可以在
@()
中将CMDLET(或Pipeline)的输出包裹起来,以确保您获得的内容是数组而不是单个项目。例如,DIR通常返回列表,但根据选项,它可能会返回一个对象。如果您打算使用foreach-object进行迭代,则需要确保返回列表。这是一个人为的示例:
另一件事...一个空数组(喜欢初始化变量)表示为
@()
。You can also wrap the output of a cmdlet (or pipeline) in
@()
to ensure that what you get back is an array rather than a single item.For instance, dir usually returns a list, but depending on the options, it might return a single object. If you are planning on iterating through the results with a foreach-object, you need to make sure you get a list back. Here's a contrived example:
One more thing... an empty array (like to initialize a variable) is denoted
@()
.剥落操作员
要创建一个数组,我们创建一个变量并分配数组。数组由“@”符号指出。让我们进行上面的讨论,并使用数组连接到多台远程计算机:
它们用于数组和哈希。
PowerShell教程7:累积,回忆和修改数据
The Splatting Operator
To create an array, we create a variable and assign the array. Arrays are noted by the "@" symbol. Let's take the discussion above and use an array to connect to multiple remote computers:
They are used for arrays and hashes.
PowerShell Tutorial 7: Accumulate, Recall, and Modify Data
Array Literals In PowerShell
我希望这有助于更好地理解它。
您可以将“值”存储在键中,然后返回该值进行操作。
在这种情况中
I hope this helps to understand it a bit better.
You can store "values" within a key and return that value to do something.
In this case I have just provided @{a="";b="";c="";} and if not in the options i.e "keys" (a, b or c) then don't return a value
在PowerShell V2中, @也是 splat操作员。
In PowerShell V2, @ is also the Splat operator.