小编Eug*_*ene的帖子

如何检查Python脚本已生成的字符串的Linux Shell编码

我运行一个Python脚本,该脚本生成一个字符串,然后使用该字符串执行Shell脚本。我想使用linux shell检查该字符串的编码,但不将该字符串写入文件中(磁盘操作运行缓慢)。是否可以仅使用RAM检查Linux(Ubuntu)中的字符串编码?就像是:

check-encoding'我的随机编码字符串'

Python检查编码脚本也很慢。

python linux string shell encoding

5
推荐指数
1
解决办法
2034
查看次数

Twig不正确的截断html

我将数据库中的新闻文本保存为HTML:

<p>Hello, i'm a text!</p><p> More text</p>
Run Code Online (Sandbox Code Playgroud)

当我像这样渲染文字时

{{ post.body | raw }}
Run Code Online (Sandbox Code Playgroud)

一切顺利,但我需要将文本截断为20-30个符号,以便在主页上进行预览.所以,我试过了

{{ p.body[:20] ~ '..' }} 
Run Code Online (Sandbox Code Playgroud)

然后文字看起来像

<p>Hello, i'm..
Run Code Online (Sandbox Code Playgroud)

如何隐藏比HTML标签?"| raw"过滤器在截断时也不起作用.请帮忙

html truncate twig

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

标签 统计

encoding ×1

html ×1

linux ×1

python ×1

shell ×1

string ×1

truncate ×1

twig ×1