【发布时间】:2013-01-09 15:52:43
【问题描述】:
我正在通过深入研究自学python。如果你把它留空,我不确定一个函数是否会这样做:
#My first section that pulls a value from a random shuffle of codes
print "\n"
print "-"*10
print 'This is a test of the %s system'% codes[0]
print "-"*10
print "\n"
#My second section that pulls a value from a random shuffle of codes
print "\n"
print "-"*10
print 'This is not a test of the %s system and all is good'% codes[1]
print "-"*10
print "\n"
我的问题是,有没有办法让它看起来更好看并且代码行更少?还是我坚持打印 10 行?
【问题讨论】:
-
每个人都有这么好的答案。我尝试了所有这些,它们工作得很好。我选择了最适合我的目的的一个。非常感谢大家的精彩意见。
标签: python dictionary function