Created
August 25, 2017 04:16
-
-
Save a8568730/17668664ada5ec41d8c76ecf6f7c5cc5 to your computer and use it in GitHub Desktop.
臺灣言語資料庫練習:華台辭典
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import csv | |
from 臺灣言語資料庫.資料模型 import 外語表 | |
from django.forms.models import model_to_dict | |
def 顯示表格(): | |
for 一筆 in 外語表.objects.all(): | |
print(model_to_dict(一筆)) | |
# | |
# 主要程式 | |
# | |
HuaTaiCsv = """ID,華語對譯,英文,台語羅馬字,台語漢字 | |
1,曾祖父母,grandparents,a-chou2,阿祖 | |
2,爺爺,grandfather,a-kong,阿公 | |
3,媽媽,mother,a-bo2,阿母 | |
""" | |
f = io.StringIO(HuaTaiCsv) | |
reader = csv.DictReader(f, delimiter=',') | |
for row in reader: | |
print(row) | |
顯示表格() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment