中缀运算符将子进程输出管道化到python函数

2024-05-23 22:42:00 发布

您现在位置:Python中文网/ 问答频道 /正文

xonsh能否将子进程输出到python函数?你知道吗

int($(ls|wc -l)) > 20

作为

ls | wc -l  | int > 20

我可以靠近

from toolz import pipe
pipe($(ls |wc -l),int) > 20

这是寻找港口的方法

# bash
[ $(ls |wc -l ) -gt 20 ] && echo busy dir
# xonsh
test @$(ls |wc -l)  '-gt' 20 and echo busy dir
# xonsh with more python 
len(`[^.].*`) > 20 and echo busy dir

但一般来说,我希望中缀运算符是lamagrittr的前向管道%>%coconut's|>


Tags: and函数fromechogt进程dirls