序列乘法示例与成员资格验证示例
cur =raw_input("input you real name:") screen_width=80 box_width = len(cur)+6 left_width = (screen_width-box_width)//2 序列乘法示例
print print ' '*left_width+'+'+'-'*(box_width-6)+ '+' print ' '*left_width+'|'+' '*len(cur) + '|' print ' '*left_width+'|' +cur+ '|' print ' '*left_width+'|'+' '*len(cur) + '|' print ' '*left_width+'+'+'-'*(box_width-6)+ '+' print
通过利用乘法标签'*' 打印出来的效果是:
input you real name:zhang san +---------+ | | |zhang san| | | +---------+
成员资格验证示例
>>> users = [['admin','admin'],['zzp','zzp'],['plllp','plllp']] >>> username = raw_input("input you username:") input you username:zzp >>> userpass = raw_input("input you password") input you passwordzzp >>> if [username,userpass] in users:print'user is checked' user is checked >>>