当前位置: 首页 > 后端技术 > Python

[python]python代码的缩进

时间:2023-03-26 11:51:06 Python

没有加着色功能,比较麻烦,比如变量的颜色和函数的颜色,需要用到正则表达式。使用博客自带的python代码着色,改成如下:print(''+all+'')效果和代码是如下:#-*-coding:utf-8-*-codedic={'"':'"',"'":''','<':'<','>':'>','&':'&'}codekey=codedic.keys()filename=input('输入文件路径:')print(filename)f=open(filename,'r')all=''forlineinf:ltmp=''forcinline:ifcincodekey:ltmp+=codedic[c]eliford(c)==9:ltmp+=''eliford(c)==32:ltmp+=''else:ltmp+=call=all+''+ltmp+'

'f.close()print(''+all+'')