import os def convert_to_png(input_filenames): for filename in input_filenames: if filename.endswith('.jpg') or ('.JPG'): output_filename = os.path.splitext(filename)[0] + '.png' print(output_filename) # 讀取輸入檔案名稱 input_filenames = [] while True: try: filename = input() if filename == 'EOF': break input_filenames.append(filename) except EOFError: break # 轉換圖像格式 convert_to_png(input_filenames)