Powershell 单引号与双引号 [英] Powershell single quote vs double quote

查看:89
本文介绍了Powershell 单引号与双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道使用单引号而不是双引号的区别在于变量不会被扩展.

I know that difference between using single quote instead of double quote is that variables aren't expanded.

$a = "hello"
"$a world"    # hello world
'$a world'    # $a world

我习惯使用双引号,但我想单引号可能更有效.这总是真的吗?有关于这个主题的一些文档吗?我用谷歌搜索了一下,但结果被关于扩展变量的解释淹没了

I am accustomed to use double quote, but I guess that single quote could be more efficient. Is this always true? Is there some documentation about this topic? I googled a bit but results are overwhelmed by explanation about expanding variables

推荐答案

如果您没有嵌入变量或子表达式,效率很可能不是问题.

Efficiency is very probably a non-issue if you don't have embedded variables or subexpressions.

使用 Measure-Command 进行的快速测试显示没有任何区别.

A quick test with Measure-Command showed no difference at all.

这篇关于Powershell 单引号与双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆