String 如何用“内部”封装脚本&“,与“外部”&引用@
我有一个脚本,其中包含String 如何用“内部”封装脚本&“,与“外部”&引用@,string,powershell,String,Powershell,我有一个脚本,其中包含@@: $myHtml = @" <html> ... </html> "@ 但我得到一个错误: 我可以通过从字符串中读取字节并将其转换为ASCII来解决问题: # Read the entire file to an array of bytes. $bytes = [System.IO.File]::ReadAllBytes("path_to_my_script") # Convert to a text assuming ASCII en
@@
:
$myHtml = @"
<html>
...
</html>
"@
但我得到一个错误:我可以通过从字符串中读取字节并将其转换为ASCII来解决问题:
# Read the entire file to an array of bytes.
$bytes = [System.IO.File]::ReadAllBytes("path_to_my_script")
# Convert to a text assuming ASCII encoding.
$text = [System.Text.Encoding]::ASCII.GetString($bytes)
但我想学习如何用内部的
@“@
和外部的@
封装脚本,只需将字符串引号更改为单引号,而不是双引号:
$string = @'
$myHtml = @"
<html>
...
</html>
"@
'@
$string=@'
$myHtml=@”
...
"@
'@
看
$string = @'
$myHtml = @"
<html>
...
</html>
"@
'@