세 개의 인수 입력 파일, 출력 파일 및 백분율 값이 필요한이 python 코드를 사용하여 다른 형식으로 파일을 변환하려고합니다. 쉘 스크립트에서 파이썬 함수를 호출하고 그것은 처음에는 정상적으로 작동하지만 두 번째에는 작동하지 않습니다. 오류는 "IOError : [Errno 2] 해당 파일이나 디렉토리가 없습니다 : 'ux_source_2850.txt'. 하지만이 파일이이 디렉토리에 있음을 확신합니다. 누군가 나를 도울 수 있습니까? 또한, 파이썬 함수를 호출하는 또 다른 방법이 있다면 궁금 해서요, 그래서 컴파일 된 C 함수처럼, 여러 인수와 함께 함수를 실행할 수 있습니다.IOError : [Errno 2] 해당 파일이나 디렉토리가 없습니다. 'ux_source_2850.txt
#!/usr/bin/env python
def convertfile(file1,file2,percentage):
with open(file1, "r+") as infile, open(file2, "w+") as outfile:
outfile.write('lon lat Ve Vn Se Sn Cen Site Ref\n')
for line in infile.readlines():
line = line.strip()
new_line=line + " "+percentage+" "+percentage+" "+'0.05 stat(0,0) test1'+'\n'
outfile.write(new_line)
file1=raw_input()
file2=raw_input()
percentage=raw_input()
convertfile(file1,file2,percentage)
#!/bin/bash
infile1=ux_source_$j.txt
outfile1=ux_$j.txt
percentage1=`sort biggest_z_amp | tail -1 | awk '{print $1*2e4}'`
../convertfile.py<<!
$infile1
$outfile1
$percentage1
!
infile2=uy_source_$j.txt
outfile2=uy_$j.txt
../convertfile.py<<!
$infile2
$outfile2
$percentage1
!
"하지만 난이 파일이이 디렉토리에 확신"당신은 정말 확실 : 여전히
더 나은는 사용할 수 있습니까? 나는 이것이 실패 할 유일한 이유는 파일이 실제로 존재하지 않는다는 것입니다. – CDspace