#1573: a317ans


1652401-2@g.puiching.edu.mo (P6D14林建壹)

School : Pui Ching Middle School
ID : 2963
IP address : [192.168.120.33]
Last Login :
2024-11-05 12:14:44
a317. 輸入jpg/輸出png | From: [192.168.120.33] | Post Date : 2024-05-22 11:42

import os

def convert_to_png(input_filenames):
    for filename in input_filenames:
        if filename.endswith('.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)
 
ZeroJudge Forum