小编Dav*_*vid的帖子

将字符串转换为参数时,Bash不解析引号

这是我的问题.在bash 3中:

$ test='One "This is two" Three'
$ set -- $test
$ echo $2
"This
Run Code Online (Sandbox Code Playgroud)

如何获得的bash了解行情,并返回$ 2作为This is two和不"This?不幸的是,我不能改变test这个例子中调用的变量的构造.

string bash arguments spaces quoting

11
推荐指数
2
解决办法
2981
查看次数

Python中的循环效率更高(单行?)

我把这个代码放在一起,生成一串11个随机可打印的ascii字符:

import random
foo=[]
for n in range(11):
    foo.append(chr(random.randint(32,126)))
print "".join(foo)
Run Code Online (Sandbox Code Playgroud)

它工作正常,但我不禁觉得可能有一种比称"追加"11次更有效的方法.有什么提示让它更像Pythonic?

python for-loop

0
推荐指数
1
解决办法
2170
查看次数

标签 统计

arguments ×1

bash ×1

for-loop ×1

python ×1

quoting ×1

spaces ×1

string ×1