Ainsteinx Logo
Ainsteinx
👤
欢迎使用 Ainsteinx
登录

切换语言

货币

首页
博客
服务
全部课程
EP.6 老挝人的 Python

字典:Python 里的词典

words = {"ໝາ": "dog", "ແມວ": "cat", "ນົກ": "bird"}

print(words["ແມວ"])
words["ປາ"] = "fish"
print(len(words))
视频即将上线
EP.6 数据与结构

字典:Python 里的词典

用 dict 查老挝语 → 英语的翻译。

字典在花括号 { } 中以“键: 值”对的形式存储数据。按键取值,而不是按位置。

适合有名字的数据,比如商品价格或朋友的电话号码。

ep06-dictionaries.py
words = {"ໝາ": "dog", "ແມວ": "cat", "ນົກ": "bird"}

print(words["ແມວ"])
words["ປາ"] = "fish"
print(len(words))

输出结果

cat
4
  • #PythonສຳລັບຄົນLaos
  • #Python
  • #ຮຽນໂປຣແກຣມ
  • #ບອກຕໍ່ຄວາມຮູ້
  • #shorts

观看并分享到