python-打印简单公司员工信息表
知识点:
raw_input
str转int
whil
if elif else continue break
for
导入模块
引用变量值
格式化输出
vim
#!/usr/bin/env python
import sys
user_name = "carson"
this_year = 2014
counter = 0
while True:
if counter < 3:
name = raw_input("please input your name:").strip()
if len(name) == 0:
print "empty name , please input your name again!"
continue
elif name == user_name:
pass
print "welcome to login system!"
else:
print "%s is a not valid user, please try again!" % name
counter = counter + 1
continue
break
else:
print "Your input 3 times!"
sys.exit()
break
age = int(raw_input("How old are you?"))
sex = raw_input("please input your sex:")
hobby = raw_input("Do you hava any hobbies?")
information = '''Information of company staff
Name :%s
Age :%d
Sex :%s
Hobby:%s
''' % (name,age,sex,hobby)
print information
输入3次,退出程序!
# python carson.by
please input your name:a
a is a not valid user, please try again!
please input your name:b
b is a not valid user, please try again!
please input your name:c
c is a not valid user, please try again!
Your input 3 times!
输入空白字符,提示一直输入
# python carson.by
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
please input your name:
empty name , please input your name again!
输入正确:
please input your name:carson
welcome to login system!
How old are you?23
please input your sex:M
Do you hava any hobbies?football
Information of company staff
Name :carson
Age :23
Sex :M
Hobby:football
在判断输入次数的还有一种方法是利用for循环:
#!/usr/bin/env python
import sys
user_name = "carson" while True:
name = raw_input("please input your name:").strip()
if len(name) == 0:
print "empty name , please input your name again!"
continue
for i range(1,3):
name = raw_input("please input your name:").strip()
if name == user_name:
pass
print "welcome to login system!"
else:
print "%s is a not valid user, please try again!" % name
continue
break
else:
print "Your input 3 times!"
sys.exit()
break
age = int(raw_input("How old are you?"))
sex = raw_input("please input your sex:")
hobby = raw_input("Do you hava any hobbies?")
information = '''Information of company staff
Name :%s
Age :%d
Sex :%s
Hobby:%s
''' % (name,age,sex,hobby)
print information
python-打印简单公司员工信息表的更多相关文章
- python练习程序_员工信息表_基本实例
python实现增删改查操作员工信息文件,可进行模糊查询: http://edu.51cto.com/lesson/id-13276.html http://edu.51cto.com/lesson/ ...
- python作业员工信息表程序(第四周)
作业需求: 1. 员工信息表程序,实现增删改查操作: 2. 可进行模糊查询,语法至少支持下面3种: select name,age from staff_table where age > 22 ...
- python练习题-员工信息表
周末大作业:实现员工信息表文件存储格式如下:id,name,age,phone,job1,Alex,22,13651054608,IT2,Egon,23,13304320533,Tearcher3,n ...
- python基础之员工信息表作业
周末大礼包 文件存储格式如下: id, name, age, phone, job 1, Alex, 22, 13651054608, IT 2, Egon, 23, 13304320533, Tea ...
- day12 python作业:员工信息表
作业要求: 周末大作业:实现员工信息表文件存储格式如下:id,name,age,phone,job1,Alex,22,13651054608,IT2,Egon,23,13304320533,Tearc ...
- python's sixteenth day for me 员工信息表
import os user_dic = { 'username':None, 'password':None, 'login':True } flag = False name_list = ['i ...
- python-查询员工信息表
python查询员工信息表 基本要求: 用户可以模糊查询员工信息 显示匹配了多少条,匹配字符需要高亮显示 代码: #!/usr/env python #coding:utf-8 import time ...
- python3 员工信息表
这是最后一条NLP了......来吧 十二,动机和情绪总不会错,只是行为没有效果而已 动机在潜意识里,总是正面的.潜意识从来不会伤害自己,只会误会的以为某行为可以满足该动机,而又不知道有其他做法的可能 ...
- day21 05 员工信息表
day21 05 员工信息表 假设有一个员工信息表,里面有每个员工的名字,id,年龄,电话,还有他们所作的工作,而有时候我们并不需要所有的信息,而想根据某些条件,寻找符合条件即可,即筛选, 比如想要筛 ...
随机推荐
- iOS 检测版本更新
如果我们要检测app版本的更新,那么我们必须获取当前运行app版本的版本信息和appstore 上发布的最新版本的信息. 当前运行版本信息可以通过info.plist文件中的bundle versio ...
- Linux服务器集群技术的概述
目前,越来越多的网站采用Linux操作系统,提供邮件.Web.文件存储.数据库等服务.也有非常多的公司在企业内部网中利用Linux服务器提供这些服务.随着人们对Linux服务器依赖的加深,对其可靠性. ...
- win7如何开启和关闭超级管理员账户
激活命令: net user administrator /active:yes 关闭命令: net user administrator /active:no
- How to solve "The specified service has been marked for deletion" error
There may be several causes which lead to the service being stuck in “marked for deletion”. Microsof ...
- TWinControl的刷新过程(5个非虚函数,4个覆盖函数,1个消息函数,默认没有双缓冲,注意区分是TCustomControl还是Windows原生封装控件,执行流程不一样)
前提条件:要明白在TWinControl有以下四个函数的存在,注意都是虚函数: procedure Invalidate; override;procedure Update; override;pr ...
- centos 6.5关闭NetworkManager
jrhmpt01:/root# rpm -qa | grep -i network NetworkManager-glib-0.8.1-99.el6.x86_64 system-config-netw ...
- libc.so.6 误删后修复
libc.so.6 误删后修复 libc.so.6 被删除了(libc.so.6只是个链接,真实的lib 文件是 libc-2.15.so) su, sudo,ls, cp, mv 等等一系列命令都 ...
- Linux日志文件系统(EXT4、XFS、JFS)及性能分析
Ext4 ReiserFS Btrfs 等七种文件系统性能比拼 自上一篇<Ext2 v.s. Ext3 v.s. Ext4 性能比拼> 发布以来,社会各界纷纷来电来函,给出了“Ext4 我 ...
- Gold Balanced Lineup(哈希表)
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10711 Accepted: 3182 Description Farm ...
- LA3353
感觉好久没做网络流这类的题目都不快会做了 网络流建模之前首先要分析性质 选择要求每个点恰属一个环就代表每个点在选择的图中,只有唯一入度和唯一出度 那就简单了,对n个点拆点,对于原图的边i-->j ...