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,年龄,电话,还有他们所作的工作,而有时候我们并不需要所有的信息,而想根据某些条件,寻找符合条件即可,即筛选, 比如想要筛 ...
随机推荐
- linux中bin和xbin下可执行程序的区别
/bin下的都是Linux最基础的,所有用户都可以使用的外部命令 /sbin下的都是只有超级用户root才能使用的.管理Linux系统的外部命令 /usr/bin以及/usr/local/bin下的都 ...
- [BZOJ 1048] [HAOI2007] 分割矩阵 【记忆化搜索】
题目链接:BZOJ - 1048 题目分析 感觉这种分割矩阵之类的题目很多都是这样子的. 方差中用到的平均数是可以直接算出来的,然后记忆化搜索 Solve(x, xx, y, yy, k) 表示横坐标 ...
- Sublime text 2 快捷键配置文件
分屏快捷键 command+alt+2(就是view菜单中layout后跟数字,有1234,快捷键都带有提示符) 格式化快捷键 ctrl+alt+f 这里提到一个和sublime无关的..comman ...
- Atlantis
poj1151:http://poj.org/problem?id=1151 题意:求矩形面积的并题解:扫描线加线段树 #include<iostream> #include<cst ...
- PhpStorm常用快捷键大全
常用快捷键(keymaps:Default情况下)注意:部分快捷键,必须在没有更改快捷键的情况下才可以使用 功能键Esc键 返回编辑器窗口F1 打开在线帮助F2 (Shift+F2) 下/上高亮错误或 ...
- 【HDOJ】3295 An interesting mobile game
其实就是一道搜索模拟题.因为数据量小,用char就够了. /* 3295 */ #include <iostream> #include <cstdio> #include & ...
- 生成树的计数(基尔霍夫矩阵):UVAoj 10766 Organising the Organisation SPOJ HIGH - Highways
HIGH - Highways In some countries building highways takes a lot of time... Maybe that's because th ...
- 动态规划——J 括号配对问题
J - 括号匹配 Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- [已解决问题] An error occurred while automatically activating bundle com.android.ide.eclipse.adt
可以参见stackoverflow的解决方案:http://stackoverflow.com/questions/16974349/an-error-occurred-while-automatic ...
- openStack images