1
2
3
4
5
6
7
8
9
10
11
12
13
#-*- coding:utf-8 -*-
import os
import sys
 
if len(sys.argv) == 2:
    filename=sys.argv[1]
    if not os.path.isfile(filename):
        print '[-]' + filename + 'does not exist.'
        exit(0)
    if not os.access(filename, os.R_OK):
        print '[-]' + filename + 'access denied.'
        exit(0)
    print '[+] reading vulnerabilities from : ' + filename


执行结果:第一个是不存在的文件,第二个是存在且有权限的文件

Python 判断文件是否存在和权限



Python 判断文件是否存在和权限



本文转自 天道酬勤VIP 51CTO博客,原文链接:http://blog.51cto.com/tdcqvip/1944597

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2021-08-27
  • 2021-09-11
  • 2022-01-17
  • 2021-11-18
猜你喜欢
  • 2022-02-26
  • 2021-10-02
  • 2022-12-23
  • 2021-06-01
  • 2021-08-12
  • 2021-09-29
  • 2021-10-22
相关资源
相似解决方案