当我这样做时which groovy
,我得到以下输出:
/usr/local/bin/groovy
Run Code Online (Sandbox Code Playgroud)
所以我继续创建了helloworld.groovy
以下内容
#!/usr/local/bin/groovy
println "hello world"
Run Code Online (Sandbox Code Playgroud)
之后我做了chmod +x helloworld.groovy
并试图运行该文件,./hellworld.groovy
遗憾的是,我收到了这个错误./helloworld.groovy: line 2: print: command not found
我可以通过更改为删除错误
#!/usr/bin/env groovy
println "hello world"
Run Code Online (Sandbox Code Playgroud)
为什么第一种方法会导致错误?
我有以下功能,它的工作原理:
(fn x => x * 2) 2;
Run Code Online (Sandbox Code Playgroud)
但是这个不起作用:
(fn x y => x + y ) 2 3;
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么?或者给我一些暗示让它发挥作用?
我有一个像下面的xml片段
<Detail uid="6">
<![CDATA[
<div class="heading">welcome to my page</div>
<div class="paragraph">this is paraph</div>
]]>
</Detail>
Run Code Online (Sandbox Code Playgroud)
我希望能够改变
<div class="heading">...</div> to <h1>Welcome to my page</h1>
<div class="paragraph">...</div> to <p>this is paragraph</p>
Run Code Online (Sandbox Code Playgroud)
你知道我怎么能在xslt 1.0中做到这一点
从文件中,urllib.unquote_plus应该按空格重复加号.但是当我在IDLE中为python 2.7尝试下面的代码时,它没有.
>>s = 'http://stackoverflow.com/questions/?q1=xx%2Bxx%2Bxx'
>>urllib.unquote_plus(s)
>>'http://stackoverflow.com/questions/?q1=xx+xx+xx'
Run Code Online (Sandbox Code Playgroud)
我也试过做一些像是urllib.unquote_plus(s).decode('utf-8').
有一个适当的解码url组件?
我有2个文本文件.file1
包含ID列表:
11002
10995
48981
79600
Run Code Online (Sandbox Code Playgroud)
file2
:
10993 item 0
11002 item 6
10995 item 7
79600 item 7
439481 item 5
272557 item 7
224325 item 7
84156 item 6
572546 item 7
693661 item 7
.....
Run Code Online (Sandbox Code Playgroud)
我试图选择file2
ID(第一列)所在的所有行file1
.目前,我正在做的是遍历第一个文件来创建一个正则表达式:
^\b11002\b\|^\b10995\b\|^\b48981\b|^\b79600\b
Run Code Online (Sandbox Code Playgroud)
然后运行:
grep '^11002\|^10995\|^48981|^79600' file2.txt
Run Code Online (Sandbox Code Playgroud)
但是当ID的数量file1
太大(~2000)时,正则表达式会变得很长而grep
变慢.还有另外一种方法吗?我正在使用Perl + Awk + Unix.
我在文本文件中有以下数据.
10993 39750 11002
10993 39751 10995
10993 39752 48981
10993 39750 344417 79600
10985 39750 344417 475879
110010 39750 59816
Run Code Online (Sandbox Code Playgroud)
我可以使用哪些unix命令来执行"SELECT LAST_COLUMN WHERE FIRST_COLUMN ='10993'"之类的操作,结果将是:
11002
10995
48981
79600
Run Code Online (Sandbox Code Playgroud)