我已经编写了这个大函数来在我的 python 代码中进行一些格式化。无论如何,你能建议把它变小吗?
def disfun(String1,String2,String3):
if String3 == "A" or String3 == "B":
if String3 == "A":
pass
elif String3 == "B":
print "#"*54
print "##"," "*48,"##"
print "##",'{0:^48}'.format(String2),"##"
print "##",'{0:^48}'.format(String1),"##"
print "##"," "*48,"##"
print "#"*54
elif String3 == "C":
print "-"*40
print "--",'{0:^34}'.format(String2),"--"
print "-"*40
elif String3 == 'D':
String2 = ' * '.join(String2)
print "#"*54
print "##",'{0:^48}'.format(String2),"##"
print "##",'{0:^48}'.format(String1),"##"
print "#"*54
elif String3 == 'E':
print "*"*54
print "**",'{0:^48}'.format(String2),"**"
print "**",'{0:^48}'.format(String1),"**"
print "*"*54