今儿在写一脚本的时候,出现了错误查了半天:各种纠结,无奈啊,怀疑这个错误怀疑那个错误。关键是基础不牢啊:
>>> if 0: ... print 'chen' >>> if not 0: ... print 'chen' ... chen >>> if 1: ... print 'chen' ... chen >>> if 2: ... print 'ce' ... ce >>> for i in range(1,10): ... if i>7: ... break#跳出循环,执行后面的语句 ... print i ... 1 2 3 4 5 6 7 >>> for i in range(1,10): ... if i>7: ... continue#后面的语句不执行,继续下次循环 ... print i ... 1 2 3 4 5 6 7最近学习python,好好从头开始吧,把各种基础好好联系下。
7月1号:实验
>>> name='chen' >>> root='chen' >>> if root=='name': ... print '11' ... >>> if root=='%s' %name: ... print '22' ... 22 >>> print file <type 'file'> >>> file=[('-d','222'),('-e','2323')] >>> for opt,arg in file: ... if opt=='-d': ... print arg ... 222