計算機科学のブログ

ほしい物リスト

Python - Formatted String Literals: Make Charts from Data - with statement, file, write mode, print

Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly GuidePaul Barry(著)、 O’Reilly Mediaの Chapter 5.(Formatted String Literals: Make Charts from Data)、EXERCISE(277/682)の解答を求めてみる。

Jupyter(コード、入出力結果)

Charts.ipynb

import os


save_to = os.path.join(f'{fn.removesuffix('txt')}html')
with open(save_to, 'w') as f:
    print(html, file=f)