小编Sam*_*rts的帖子

如何使用 sed 删除双换行符?

我试过:

sed -i 's/\n+/\n/' file
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

我仍然想要单行中断。

输入:

abc

def


ghi




jkl
Run Code Online (Sandbox Code Playgroud)

期望的输出:

abc

def

ghi

jkl
Run Code Online (Sandbox Code Playgroud)

linux bash sed

6
推荐指数
2
解决办法
7745
查看次数

如何转义Python字符串中的任何特殊shell字符?

如何转义Python字符串中的任何特殊shell字符?

需要转义以下字符:

$,!,#,&,",',(,),|,<,>,`,\,;
Run Code Online (Sandbox Code Playgroud)

比如说我有这个字符串:

str="The$!cat#&ran\"'up()a|<>tree`\;"
Run Code Online (Sandbox Code Playgroud)

TIA

python bash shell

4
推荐指数
1
解决办法
3596
查看次数

如何在Python中将0x1b87打印为\ x1b\x87?

我怎样才能0x1b87\x1b\x87Python 一样打印?

$ python
Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> hex(0x0d90 ^ 0x1617)
'0x1b87'
Run Code Online (Sandbox Code Playgroud)

python hex

2
推荐指数
1
解决办法
124
查看次数

标签 统计

bash ×2

python ×2

hex ×1

linux ×1

sed ×1

shell ×1