没有文件扩展名的权限错误

Permission error without a file extension

我有一个 python 程序可以扫描目录中的所有文件,但是当我想打开一个没有扩展名的文件时 C:\path\to\file\actual file,然后 python 给了我一个权限拒绝 error.How 我可以解决这个问题吗?

我的意思是没有扩展名是它没有 .exe 或 .txt 或类似的东西 that.How 我可以读取文件而不手动添加文件扩展名吗?

这是完整的错误:

Traceback (most recent call last):
  File "scan.py", line 152, in <module>
    file = open(i,'r')
PermissionError: [Errno 13] Permission denied: 'C:\path\to\file\my_file'

好的,除了我的评论所述,我不知道为什么它不起作用,但是这个程序适用于 windows。

import os
s = "H:\path\to\file\ActualFile"
for subdir, dirs, files in os.walk(s):
    for file in files:
        try:
            GatheredFiles = (os.path.join(subdir, file))
        except PermissionError:
            print("You do not have permision to go in here"))
            break

编辑:添加了 try 语句