命令行版“瑞士军刀” Pythonpy

码农软件 · 软件分类 · 常用工具包 · 2019-08-13 19:27:16

软件介绍

Pythonpy 可看作是命令行版的“瑞士军刀”,能在命令行中直接执行任何 Python 指令。

Usage

浮点运算

$ py '3 * 1.5'
4.5

自动导入任意模块

$ py 'math.exp(1)'
2.71828182846

$ py 'random.random()'
0.103173957713

$ py 'datetime.datetime.now?'
Help on built-in function now:

now(...)
      [tz] -> new datetime with tz's local day and time.

py -x'foo(x)'将 foo 应用到输入的每行

将输入的各行乘以7

$ py 'range(3)' | py -x 'int(x)*7'
0
7
14

抓住 csv 的第二列

$ echo $'a1,b1,c1\na2,b2,c2' | py -x 'x.split(",")[1]'
b1
b2

将 “.text” 附加到目录中的每个文件

$ ls | py -x '"mv `%s` `%s.txt`" % (x,x)' | sh
# sharp quotes are swapped out for single quotes
# single quotes handle spaces in filenames

删除 find 命令返回的每个文件

$ find . -type f | py -x '"rm %s" % x' | sh

只获取2位数字

$ py 'range(14)' | py -x 'x if len(x) == 2 else None'
10
11
12
13

本文地址:https://codercto.com/soft/d/12298.html

Remote

Remote

Jason Fried、David Heinemeier Hansson / Crown Business / 2013-10-29 / CAD 26.95

The “work from home” phenomenon is thoroughly explored in this illuminating new book from bestselling 37signals founders Fried and Hansson, who point to the surging trend of employees working from hom......一起来看看 《Remote》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具