gpt4 book ai didi

python - 读取文件python时出错

转载 作者:太空宇宙 更新时间:2023-11-04 09:05:15 24 4
gpt4 key购买 nike

<分区>

我正在尝试读取目录中的 python 文件。我收到一个错误

Traceback (most recent call last):
File "/home/akallararajappan/codes to handle unicode/read_directory.py", line 42, in <module>
open_file( filename)
File "/home/akallararajappan/codes to handle unicode/read_directory.py", line 31, in open_file
data = open (fil_name, 'r').read()
IOError: [Errno 2] No such file or directory: 'createFile.py'

这是我的代码:

import os
import codecs
def open_file(fil_name) :
data = open (fil_name, 'r').read()
print data



for dirname, dirnames, filenames in os.walk('/home/akallararajappan/corpus'):
print()
#print(dirname + ":")
for filename in filenames:
open_file( filename)

这里有什么问题?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com