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,年龄,电话,还有他们所作的工作,而有时候我们并不需要所有的信息,而想根据某些条件,寻找符合条件即可,即筛选, 比如想要筛 ...
随机推荐
- MFC 如何改变对话框按钮上的文字
原文地址:http://blog.163.com/wenxianliang08@126/blog/static/8358326320110300643282/ 什么是标记菜单 如何标记菜单 如何 ...
- matplotlib.pyplot 绘图详解 matplotlib 安装
apt-get install python-matplotlib 转载自: http://www.cnblogs.com/qianlifeng/archive/2012/02/13/2350086. ...
- 总结iOS 8和Xcode 6的各种坑
模拟器的路径从之前的~/Library/Application Support/iPhone Simulator移动到了~/Library/Developer/CoreSimulator/Device ...
- 【Java】java的内存浅析
一.闲谈下 201407月记着那时候身体垮了下来,呵呵.想说,对自己的说,也是对大家的负责吧.那时候胸疼胸闷,然后几乎累垮了,我还坚持了一星期,那一星期真的迷迷糊糊.完全不能看代码,看代码就晕.一直想 ...
- Sublime text 2 快捷键配置文件
分屏快捷键 command+alt+2(就是view菜单中layout后跟数字,有1234,快捷键都带有提示符) 格式化快捷键 ctrl+alt+f 这里提到一个和sublime无关的..comman ...
- (step4.3.8)hdu 2181(哈密顿绕行世界问题——DFS)
题目大意:通俗点讲就是,输出所有从m城市出发,便利所有城市之后又能回到m城市的序列...... 解题思路:DFS 1)用map[][]来存储城市之间的连通情况.用used[]存储某个城市的使用情况(即 ...
- 算法学习之C语言基础
算法学习,先熟悉一下C语言哈!!! #include <conio.h> #include<stdio.h> int main(){ printf(+); getch(); ; ...
- code_analyzer(代码分析助手)
软件名: code_analyzer 使用c语言 pcre正则库分析源码文件,包括文件中的头文件.宏定义.函数. 用途: 无聊时,可以用来打发下时间. 演示: 对于本源程序的分析结果如下: ##### ...
- 【贪心】HDU 5783 Divide the Sequence
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5783 题目大意: 把一个N个数的数列拆成若干段,保证每一段的前缀和都非负,求最多能拆成多少段. 题目 ...
- 数据库系统概论 SQL
--(一)创建教材学生-课程数据库 create database s_c go use s_c go --建立“学生”表Student,学号是主码,姓名取值唯一. CREATE TABLE Stud ...