这是我写的读取目录中文件的代码
该代码第一次运行良好,但此后出现错误:[Errno 2] 没有这样的文件或目录:'ISS_Ackermann.data.amd'
代码:
path = r'C:\Users\Tarun\Desktop\ISS_Ackermann\Platformlibrary\Package\VehicleDynamicsController\ISS\Feedforward'
# Read every file in directory
for filename in os.listdir(path):
with open(filename,"r") as f:
# Read each line of the file
for line in f.readlines():
bs_data = bs_data + line
with io.open("shouldget.xml","w",encoding='utf-8') as output:
output.write(str(bs_data))
print(bs_data)
我已经尝试过针对类似问题给出的方法,但没有任何效果