[問題] python的字串型態

看板Python作者 (hank)時間9年前 (2015/10/28 01:44), 編輯推噓1(108)
留言9則, 5人參與, 最新討論串1/1
大家好 各位前輩好 我有兩個問題想請教前輩們 第一.Should strings be simply a special kind of character array or a primitive types? 第二.Should strings have static or dynamic length? 最近再學程式語言,看到這兩個題目,不知道如果是以python的字串型態來想會是什麼 感謝各位前輩解惑 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.35.80.253 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1445967842.A.11D.html

10/28 09:30, , 1F
primitive types, static length
10/28 09:30, 1F

10/28 09:40, , 2F
Python 只有 string 而已欸, py2 好像有 char 可是py3沒
10/28 09:40, 2F

10/28 10:26, , 3F
了解!感謝兩位前輩的指導
10/28 10:26, 3F

10/28 11:24, , 4F
Python 2 也沒有 char, Guido 認為 character 是 string
10/28 11:24, 4F

10/28 11:25, , 5F
的特例, 所以沒有 character type
10/28 11:25, 5F

10/28 12:16, , 6F
感謝前輩解惑!
10/28 12:16, 6F

10/28 22:56, , 7F
有人認為python沒有primitive types,全部都是object
10/28 22:56, 7F

10/28 22:58, , 8F
如果用sys.getsizeof()來看string size,不覺得是static
10/28 22:58, 8F

10/28 23:00, , 9F
google "Check if a variable's type is primitive"
10/28 23:00, 9F
文章代碼(AID): #1MBxVY4T (Python)