python运行系统找不到指定文件,WinError 2系统找不到指定的文件(Python)

在尝试使用Python的subprocess模块批量执行Fortran程序时遇到错误,WinError 2提示系统找不到指定的文件。尝试了不同方式修正路径,包括使用os.path.normcase规范化路径,但问题仍然存在,错误涉及到文件权限和路径正确性。
摘要由CSDN通过智能技术生成

I have a Fortran program and want to execute it in python for multiple files. I have 2000 input files but in my Fortran code I am able to run only one file at a time. How should I call the Fortran program in python?

My Script:

import subprocess

import glob

input = glob.glob('C:/Users/Vishnu/Desktop/Fortran_Program_Rum/*.txt')

output = glob.glob('C:/Users/Vishnu/Desktop/Fortran_Program_Rum/Output/')

f = open("output", "w")

for i in input:

subprocess.Popen(["FORTRAN ~/C:/Users/Vishnu/Desktop/Fortran_Program_Rum/phase1.f", "--domain "+i])

f.write(i)

Error:

runfile('C:/Users/Vishnu/Desktop/test_fn/test.py', wdir='C:/Users/Vishnu/Desktop/test_fn')

Traceback (most recent call last):

File "", line 1, in

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值