• python


    >>> f=open('passwd','r')
    >>> for lines in f:
    ... print lines

    >>> f=open('passwd','r')
    >>> for lines in f:
    ...     print lines
    ... 
    root:x:0:0:root:/root:/bin/bash
    
    bin:x:1:1:bin:/bin:/sbin/nologin
    
    daemon:x:2:2:daemon:/sbin:/sbin/nologin
    
    adm:x:3:4:adm:/var/adm:/sbin/nologin
    
    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
    
    sync:x:5:0:sync:/sbin:/bin/sync
    
    shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
    
    halt:x:7:0:halt:/sbin:/sbin/halt
    
    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
    
    uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
    
    operator:x:11:0:operator:/root:/sbin/nologin
    
    games:x:12:100:games:/usr/games:/sbin/nologin
    
    gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
    
    ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
    
    nobody:x:99:99:Nobody:/:/sbin/nologin
    
    dbus:x:81:81:System message bus:/:/sbin/nologin
    
    usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
    
    vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
    
    rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
    
    rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
    
    avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
    
    abrt:x:173:173::/etc/abrt:/sbin/nologin
    
    rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
    
    nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
    
    haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
    
    gdm:x:42:42::/var/lib/gdm:/sbin/nologin
    
    ntp:x:38:38::/etc/ntp:/sbin/nologin
    
    apache:x:48:48:Apache:/var/www:/sbin/nologin
    
    saslauth:x:498:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
    
    postfix:x:89:89::/var/spool/postfix:/sbin/nologin
    
    pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
    
    xguest:x:500:500:Guest:/home/xguest:/bin/bash
    
    sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    
    >>> 

    不再需要像老版本中那样调用readline():

    for lines in f.readline():
        :
  • 相关阅读:
    Java实现蓝桥杯VIP 算法训练 找公倍数
    Java实现 蓝桥杯VIP 算法训练 水仙花数
    Java实现 蓝桥杯VIP 算法训练 水仙花数
    Java实现 蓝桥杯VIP 算法训练 水仙花数
    Java实现 蓝桥杯VIP 算法训练 水仙花数
    XE6 & IOS开发之免证书真机调试(2):连接真机并运行App(有图有真相)
    使用IRP进行文件操作
    Inline Hook NtQueryDirectoryFile
    VC提交网页表单(一共八篇)
    C++ Socket UDP "Hello World!"
  • 原文地址:https://www.cnblogs.com/abclife/p/6093345.html
Copyright © 2020-2023  润新知