新析 · 免费提供绿色软件、活动线报以及其他网络资源,好货不私藏!
查找优惠券加入QQ群我想求资源
新新析特权
  • 简洁好看
    按时更新
  • 少量广告
    资源丰富
最近更新+9
上一页
下载专区
  • " alt="司非增二" />
  • 蒲察阿里虎
  • 刘招武
  • 天鶴座BZ
  • 杵三 (危宿)
  • Working dir $PWD > EOF Working dir $PWD bash,ksh或zsh中也可以用here-字串: $ tr a-z A-Z <<<"Yes it is a string" YES IT IS A STRING Windows 命令行 等价的代码目前没有找到。下列代码较为有用。 set GREETING=Hello echo %GREETING% cmd /k echo %GREETING% set GREETING=Goodbye echo %GREETING% exit echo %GREETING% C:\> C:\>set GREETING=Hello C:\>echo %GREETING% Hello C:\>cmd /k C:\> echo %GREETING% Hello C:\> set GREETING=Goodbye C:\> echo %GREETING% Goodbye C:\>exit C:\>echo %GREETING% Hello C:\> Windows PowerShell 在Windows PowerShell里,here文档表示的是here-字串。一个here-字串是由@"或@'开始,由独立成行的"@或'@结束的字串。所有在开始符号和结束符号之间的字符都被当做字面的字串。 使用双引号引起来的here-字串允许变量替换,而单引号不行。 变量替换只发生于简单变量(如$x,但不是$x.y或$x[0])。 可以将命令放进$()中来获取执行结果。 在如下的PowerShell的代码中,文字使用here-字串传递给一个函数。这个函数ConvertTo-UpperCase定义如下: PS> function ConvertTo-UpperCase($string) { $string.ToUpper() } PS> ConvertTo-UpperCase @' >> one two three >> eins zwei drei >> '@ >> ONE TWO THREE EINS ZWEI DREI 下边是一个证明了双引号的here-字串里的变量替换和命令替换的例子: $doc, $marty = 'Dr. Emmett Brown', 'Marty McFly' $time = [DateTime]'Friday, October 25, 1985 8:00:00 AM' $diff = New-TimeSpan -Minutes 25 @" $doc : Are those my clocks I hear? $marty : Yeah! Uh, it's $($time.Hour) o'clock! $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow. $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())? $doc : Precisely. $marty : Damn! I'm late for school! "@ 输出: Dr. Emmett Brown : Are those my clocks I hear? Marty McFly : Yeah! Uh, it's 8 o'clock! Dr. Emmett Brown : Perfect! My experiment worked! They're all exactly 25 minutes slow. Marty McFly : Wait a minute. Wait a minute. Doc... Are you telling me that it's 08:25? Dr. Emmett Brown : Precisely. Marty McFly : Damn! I'm late for school! 如果用单引号的here-字串代替,输出看起来会像这样: $doc : Are those my clocks I hear? $marty : Yeah! Uh, it's $($time.Hour) o'clock! $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow. $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())? $doc : Precisely. $marty : Damn! I'm late for school! 编程语言 C++ C++11引入了原始字面字串。原始字面字串的前缀有一个“R”,以"分隔符(开始,以)分隔符"结束。分隔符可以是0到16字符长,可以包括简单的字符,除开空格,括号与反斜杠。 char const *a = R"(The escape sequence '\n' represents a newline character.)"; wchar_t const *b = LR"...(Raw strings look like R"(...)")..."; char16_t const *b = uR"xyz( Universal character names such as "\u5367\u864E\u85CF\u3863" are not processed in raw string literals. Therefore the above can be written as "臥虎藏龍" in a raw string literal, but only if the source character set contains those characters. )xyz"; D语言 从2.0版本开始,D语言支持用“q”引导的here-字串。这些字串以一个括号(<>,[],(),{})或者单独成行的标识符开始。 下列D代码展示了使用括号和标识符的here-字串。 int main() { string list = q"[1. Item One 2. Item Two 3. Item Three]"; writef( list ); } 使用标识符: int main() { string list = q"IDENT 1. Item One 2. Item Two 3. Item Three IDENT"; writef( list ); } Lua Lua使用[[和]]定义字面字串,字面字串中的换行会原样保留,不允许含有转义字符。这不便放置长的注释(--[[注释]])和一些字串(x = a[b[c]])。所以在版本5.1时,Lua添加了一个新语法:起始的两个括号中间可以加入任意多的等号,并且只有相同的等号数字才能关闭字串。

    " alt="Here文档" />
  • 孔雀座Y
  • 車府增七
  • 梅麗莎·梅爾
  • 多耙鮻
  • 瓠瓜一
  • 弗氏魢