博客园之右侧,文字实现。装逼文字
1.从网上找一句话,你喜欢的话。
2.然后转化为html所需要的格式,
3.然后插入到博客园后端代码中,等待渲染。
4.优化:在js中多写几条,随机去取
5.解析代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from icecream import ic # 传入你想操作的骚话 key = "我一定要在黄昏之前到达,我要看到我的爱人在夕阳里娇艳的容颜,和风铃响起时她迎风漫舞的衣裙" marks = ",,。.!!??" # 网上可能存在多种标点符号 preStr = " " # 这个是梯度多大的梯度 fillstr = " " # 这个是后面用什么字符去补满 s = "" # 初始化返回的字符变量 br = "<br>" # 换行符字符 colWidth = " " #这个是列之间的宽度默认4个空格 fourStrWidth = " " #4个字符宽度变量 # 统一标点符号 for i in marks: key = key.replace(i,",") arr = key.split(",") preLine = 3 # 前面要加多少行 for i in range(preLine): s+=br # 先让左边有一个梯度 for i in range(len(arr)): tempS = i*preStr arr[i] = f"{tempS}{arr[i]}" # 然后取相等长度 maxlength = max([len(i) for i in arr]) for i in range(len(arr)): arr[i] = arr[i].ljust(maxlength,fillstr) for i in range(maxlength): for index in arr: if index[i] == fillstr: s = f"{s}{colWidth}{fourStrWidth}" else: s = f"{s}{colWidth}{index[i]}" s = s + br print(s)
-----------------------------------------------------------------------------------------------------------------------------------------