没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
3页
This repeats the sorted user lister given earlier. There are two differences: The program reads directly from the password file, rather than standard input. If a file name is specified on the command line, the program reads that. Otherwise, it reads /etc/passwd.
资源推荐
资源详情
资源评论
#!/usr/bin/python
# List the account and human names from the passwd file in sorted order.
# If there is no human name, or it equals the userid, then the name is
# printed as [ none ]. The program reads from the file given the command
# line, if any, else it reads from /etc/passwd. If the file open fails, the
# program will die on an exception.
# The from form of of import adds name to the symbol table of the
# importing program, so that the names may be refered to without
# the qualified module name.
from sys import argv
from string import *
# Dictionary of entries.
iddict = { }
# Get the file name. Note that argv[0] contains the name of the script,
# so we're getting argv[1], if there is one.
infile = '/etc/passwd'
if len(argv) > 1:
infile = argv[1]
# Attempt to open the file. Will just let the program die on the exception
# if the open fails.
fin = open(infile, 'r')
# Loop through each input line.
for line in fin.readlines():
# Lines starting with # are comments. Clean leading spaces, and
# List the account and human names from the passwd file in sorted order.
# If there is no human name, or it equals the userid, then the name is
# printed as [ none ]. The program reads from the file given the command
# line, if any, else it reads from /etc/passwd. If the file open fails, the
# program will die on an exception.
# The from form of of import adds name to the symbol table of the
# importing program, so that the names may be refered to without
# the qualified module name.
from sys import argv
from string import *
# Dictionary of entries.
iddict = { }
# Get the file name. Note that argv[0] contains the name of the script,
# so we're getting argv[1], if there is one.
infile = '/etc/passwd'
if len(argv) > 1:
infile = argv[1]
# Attempt to open the file. Will just let the program die on the exception
# if the open fails.
fin = open(infile, 'r')
# Loop through each input line.
for line in fin.readlines():
# Lines starting with # are comments. Clean leading spaces, and
资源评论
sinat_19499843
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功