[英]Format decimal in shell command
Input 输入项
CTCF_1276 4.006055058150985e-03
CTCF_1274 1.726979566495019e-02
Output 输出量
CTCF_1276 4.00606e-03
CTCF_1274 1.72698e-02
I know awk
can do this very easily, but I don't like it because I need to escape the %.5e
in the string if I want to call it from python. 我知道
awk
可以很容易地做到这一点,但是我不喜欢它,因为如果我想从python调用它,我需要对字符串中的%.5e
进行转义。 Does anyone have better way to do this? 有谁有更好的方法做到这一点?
bash: 重击:
printf '%.5e' 4.006055058150985e-03
python: 蟒蛇:
print('{:.5e}'.format(4.006055058150985e-03))
perl: perl:
printf '%.5e', 4.006055058150985e-03
awk: awk:
printf '%.5e', 4.006055058150985e-03
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.