#!/usr/bin/env python #encoding=utf-8 import os def listdir(): path = "/tmp" dirfile = os.listdir(path) for filename in dirfile: if filename.startswith('.'): print "隐藏文件" else: print filename if __name__ == "__main__": listdir() [root@iZwz9j0rhuuld23m4jpvjiZ ~]# python a.py 隐藏文件 admin.pyc admin.py 隐藏文件 systemd-private-3c1220a3bf964a54a8b9dad5cdab2d2e-mariadb.service-tp827K systemd-private-3c1220a3bf964a54a8b9dad5cdab2d2e-ntpd.service-gtAiDZ tab.py 隐藏文件 Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> Django-1.10.7 隐藏文件 隐藏文件 Django-1.10.7.tar.gz HelloWorld hello.html [root@iZwz9j0rhuuld23m4jpvjiZ ~]# &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& #!/usr/bin/env python #encoding=utf-8 import os def listdir(): path = "/tmp" dirfile = os.listdir(path) for filename in dirfile: if not filename.startswith('.'): print filename if __name__ == "__main__": listdir() [root@iZwz9j0rhuuld23m4jpvjiZ ~]# python a.py admin.pyc admin.py systemd-private-3c1220a3bf964a54a8b9dad5cdab2d2e-mariadb.service-tp827K systemd-private-3c1220a3bf964a54a8b9dad5cdab2d2e-ntpd.service-gtAiDZ tab.py Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> Django-1.10.7 Django-1.10.7.tar.gz HelloWorld hello.html [root@iZwz9j0rhuuld23m4jpvjiZ ~]#