logo
  • 教程列表
  • SO官方文檔
  • 元組
    • 元組
    • 元組是不可變的
    • 包裝和拆包元組
    • 內建元組功能
    • 元組是元素明確的可洗和等同的
    • 索引元組
    • 反轉元素
  1. StackOverflow 文件
  2. Python Language 教程
  3. 元組
  4. 元組是元素明確的可洗和等同的

元組是元素明確的可洗和等同的

Created: November-22, 2018

hash( (1, 2) )  # ok
hash( ([], {"hello"})  # not ok, since lists and sets are not hashabe

因此,元組可以放在 set 中,也可以作為 dict 中的一個關鍵字,只有每個元素都可以。

{ (1, 2) } #  ok
{ ([], {"hello"}) ) # not ok
  • 索引元組
  • 內建元組功能

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明