Liquid sort 排序

基本用法{{ my_array | sort }} {{ my_array | sort | reverse }} 按照指定属性排序例如在 Jekyll 中按文章的日期排序 {% assign sorted_posts = site.posts | sort:"date" %}

Python 字符串替换

查找固定字符串并替换使用字符串对象的 .replace() 方法 s = 'a---c' s.replace('-','') # 'ac' s.replace('--','-') # 'a--c' 正则表达式查找并替换使用 re.sub() import re s = 'a---c' re.sub(r'[-]+', '-', s) #'a-c' 更多 re.sub 用法可参考 Python 使用正则 re.sub 做字符串