0
raw_input을 사용하여 파일의 이름을 바꾸려고합니다. 그러나 내가 그것을 바꿀 때, 그것은 새로운 이름에 파일 유형의 적절한 결말을주지 않는다. 그래서 저는 합류하려했지만 작동하지 않습니다. 감사합니다.원시 입력을 사용하여 os.path.join 만들기
import os
Base_TXT =r"C:\file.txt"
rename = raw_input('Would you like to rename the txt?')
if rename == 'yes':
new_name = raw_input('What is the new name?')
os.rename(Base_TXT, new_name)
os.path.join(new_name, '.txt')
else:
print "no rename made"
print "done"
os.rename''에 대한 호출은 실제 이름 바꾸기, 그래서, 이름 변경은'os.path.join'의 결과를 포함하지 않습니다 . –
또한,'os.path.join'이 생각하는대로 작동하지 않는다고 생각합니다. [documentation] (http://docs.python.org/2/library/os.path. html # os.path.join)을 사용하여 수행중인 작업을 이해하는지 확인하십시오. –
'os.path.join ("somefilename", ".txt")'는'somefilename/.txt'를 생성합니다. 'os.path.join()'은 올바른 경로 구분자 (유닉스 기반 시스템에서는 '/', 윈도우에서는 '\')를 사용하여 경로 이름 조각을 조인합니다. –