Python– category –
-
【Python】JSONファイルの読み込み
Python
import json filename = "xxx.json" with open(filename) as f: data = json.load(f) -
【Python】文字列のフォーマット
Python
str.format() str.format(**mapping) str.format_map(mapping) // dictのサブクラスの時に利用 https://docs.python.org/ja/3/library/stdtypes.html#str.format dict = { 'dictTitle': "xxx" } html = """<title>{title}</title> """ print(html.fo... -
PythonでMySQLを利用する方法
Python
pip install mysql-connector-python project % pip install mysql-connector-python Collecting mysql-connector-python Downloading mysql_connector_python-9.0.0-cp311-cp311-macosx_13_0_arm64.whl.metadata (2.0 kB) Downloading mysql_connector_py... -
Beautiful Soupで属性値を取得する方法
Python
<div id="origin" class="root"> <a href="xxx">xxx</a> </div> id = obj['id'] // idを取得 class = obj['class'] // classを取得 href = obj['href'] // これはできない