首页 > 其他 > 详细

HR_sorted_logon

时间:2017-03-29 21:24:44      阅读:126      评论:0      收藏:0      [点我收藏+]




#!/usr/bin/env python
#coding:utf-8

‘‘‘
Program:
    sorted the name inputed and output by number
History:
2017.03.29      Mr.liu      First release
‘‘‘


li  = []
count = 0
while count < 100:
    print "Up to 100 employees information input,and %d employee(s) already input.\n(Please input ‘ending‘ if input finish) )" %(count)
    name = raw_input(" Please input the message of employees(like:  name,number):")
    if "," in name and "," != name[0] and name.index(",") != len(name) - 1 and name.count(",") == 1:
        li.append(name)
        count += 1
    elif name == "ending":
        break
    else:
        name =raw_input("Unknown message! Please try again:")
        li.append(name)
        count += 1
else:
    li = sorted(li)
print "Employee information sheet is as follows (sorted by name):"
for i in li:
    print i
li = sorted(li, key=lambda d : int(d.split(‘,‘)[-1]))
print "Employee information sheet is as follows (sorted by number):"
for i in li:
    print i


本文出自 “12449513” 博客,请务必保留此出处http://12459513.blog.51cto.com/12449513/1911539

HR_sorted_logon

原文:http://12459513.blog.51cto.com/12449513/1911539

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!