Example #1
0
# I am very sorry for
    # * not obeying PEP8,
    # * abusing & spamming array comprehension instead of for-loop,
    # * using dynamic import although it is not dynamic,
    # * using __setitem__ to avoid variable-assignment limit in lambda,
        # (:= operator was possible, but that is implemented in Python 3.8)
    # * creating useless lambda function for each loop,
    # * finally, last but not least, using not-documented properties (in cs1 libraries)

# But I hope you TA guys enjoy this one-lined code.
# If you enjoyed this, please push 'Like' and 'Subscribe' button in git.nenw.dev (GitHub @HelloWorld017)
"""

# --- Your code ends here ---
########################################

download_message = '⬇ Download the result image file from the link below ⬇'
print('#' * len(download_message))
print(download_message)
sleep(0.1)

# Save your image object as a file.
image.save_as('./result.png')
# Show a download link for your result image file.
utils = EliceUtils()
utils.send_file('./result.png')

sleep(0.1)
print('#' * len(download_message))
Example #2
0
    # 아래 함수를 완성하세요.
    books = []
    with open(src_file) as src:
        reader = csv.reader(src, delimiter=',')

        # 각 줄 별로 대응되는 book 딕셔너리를 만듭니다.
        for row in reader:
            print(row)
            # 책 정보를 저장하는 딕셔너리를 생성합니다.
            book = {
                'title': row[0],
                'author': row[1],
                'genre': row[2],
                'pages': int(row[3]),
                'publisher': row[4]
            }
            books.append(book)

    with open(dst_file, 'w') as dst:
        # JSON 형식으로 dst_file에 저장합니다.
        json_string = json.dumps(books)
        dst.write(json_string)


# 아래 주석을 해제하고 결과를 확인해보세요.
src_file = 'books.csv'
dst_file = 'books.json'
books_to_json(src_file, dst_file)
elice_utils.send_file(dst_file)