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,年龄,电话,还有他们所作的工作,而有时候我们并不需要所有的信息,而想根据某些条件,寻找符合条件即可,即筛选, 比如想要筛 ...
随机推荐
- RabbitMQ启动出错:- unable to connect to epmd on xxxx: timeout (timed out)
yum install后启动rabbitmq报错: [root@www ~]# /etc/init.d/rabbitmq-server start Starting rabbitmq-server: ...
- __block存储类型
__block存储类型 你可以指定引入一个变量为可更改的,即读-写的,通过应用__block 存储类型修饰符.局部变量的__block 的存储和 register.auto.static 等存储类型相 ...
- easyui_tree 复选框 动态加载树
controller动态获取单位用户树 #region 下拉树菜单 /// <summary> /// 获取工作人员树菜单 /// </summary> /// <par ...
- MAC——laravel环境
apache: 目录:etc/apache2 重启:sudo apachectl restart PHP: 把/etc/php.ini.default复制并重命名/ect/php.ini 打开Load ...
- Lua table使用
days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Th ...
- 1031. Hello World for U (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1031 分析: 简单题,调整数组的输出次序就可以了. 输入数组长度为len.n1 = n3 = (l ...
- PHP去除空白字符
例子1: <?php $var = " This is a beautiful day!"; // 删除字符串中的所有空白字符(不包括全角空格) $var1 = preg_r ...
- 图论(二分图最大权独立点集):COGS 2051. 王者之剑
2051. 王者之剑 ★★★☆ 输入文件:Excalibur.in 输出文件:Excalibur.out 简单对比 时间限制:1 s 内存限制:256 MB [题目描述] 这是在阿尔托 ...
- Book for Opencv
Upcoming: Learning OpenCV: Computer Vision in C++ with the OpenCV Library The second edition of the ...
- hive 显示表分区真实对应数据路径
desc formatted l_ad_yclick_html partition (datecol='20160118');