0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【便利ツール】クオーテーションなしの文字列をHTMLのタグにぶち込みたい人が参考にする記事はこちら!

Posted at

フツーに困った

あるWebアプリを作ろうとしたとき、API呼び出しに使える国略称をプルダウンするためにHTMLのoptionタグで囲みたかったのに、
image.png

APIページに載っている国略称一覧が、クオーテーションすらないベタ打ち文字だった:scream:
image.png

自由に使ってね

ぱっと使えるコードがすぐには見つからなかったから、とりあえずPythonで作ったよ。

addTags.py
nations = 'ar, az, be, bg, bn, bs, cs, da, de, dz, el, en, en-gb, en-us, es, et, fa, fi, fil, fr, he, hi, hr, hu, hy, id, is, it, ja, ka, kk, km, ko, lb, lo, lt, lv, mk, mn, ms, my, ne, no, pl, pt, ro, ru, sk, sl, sq, sr, sv, sw, th, tk, uk, vi, zh'

nations_list = nations.split(', ')

for nation in nations_list:
    print("<option>" + nation + "</option>")

print(nations_list)

リストの中身をそのままprintしたから、ついでにクオーテーション付きの国略称をコピペすることもできるよ~

出力結果
<option>ar</option>
<option>az</option>
<option>be</option>
<option>bg</option>
<option>bn</option>
<option>bs</option>
<option>cs</option>
<option>da</option>
<option>de</option>
<option>dz</option>
<option>el</option>
<option>en</option>
<option>en-gb</option>
<option>en-us</option>
<option>es</option>
<option>et</option>
<option>fa</option>
<option>fi</option>
<option>fil</option>
<option>fr</option>
<option>he</option>
<option>hi</option>
<option>hr</option>
<option>hu</option>
<option>hy</option>
<option>id</option>
<option>is</option>
<option>it</option>
<option>ja</option>
<option>ka</option>
<option>kk</option>
<option>km</option>
<option>ko</option>
<option>lb</option>
<option>lo</option>
<option>lt</option>
<option>lv</option>
<option>mk</option>
<option>mn</option>
<option>ms</option>
<option>my</option>
<option>ne</option>
<option>no</option>
<option>pl</option>
<option>pt</option>
<option>ro</option>
<option>ru</option>
<option>sk</option>
<option>sl</option>
<option>sq</option>
<option>sr</option>
<option>sv</option>
<option>sw</option>
<option>th</option>
<option>tk</option>
<option>uk</option>
<option>vi</option>
<option>zh</option>
['ar', 'az', 'be', 'bg', 'bn', 'bs', 'cs', 'da', 'de', 'dz', 'el', 'en', 'en-gb', 'en-us', 'es', 'et', 'fa', 'fi', 'fil', 'fr', 'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'ko', 'lb', 'lo', 'lt', 'lv', 'mk', 'mn', 'ms', 'my', 'ne', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'sw', 'th', 'tk', 'uk', 'vi', 'zh']
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?