【python】python代码的缩进
# -*- coding: utf-8 -*-codedic={'"':'"',"'":''','<':'<','>':'>','&':'&'}
codekey=codedic.keys()
filename=input('input file path:')
print(filename)
f=open(filename,'r')
all=''
for line in f:
ltmp=''
for c in line:
if c in codekey:
ltmp+=codedic
elif ord(c)==9:
ltmp+=' '
elif ord(c)==32:
ltmp+=' '
else:
ltmp+=c
all=all+'<p style="margin-top: 0px; margin-bottom: 0px;">'+ltmp+'</p>'
f.close()
print('<pre class="brush:python;toolbar:false">' + all +'</pre>')
页:
[1]