[問題] 超級笨的笨問題
我今天剛接觸 python
請大家多多指教
在前面的某篇教學文件中
http://www.freebsd.org.hk/html/python/tut_tw/tut.html
抱歉我不會縮網址
裡面寫到
如同在C語言一樣,字串是有標記(subscript(index))的,第一個字元的標記(subscript(index))就是0。在Python中沒有另外一個字元character資料型態,一個字元就是一個長度為 1的字串。就像是在Icon語言一樣,字串是可以用其subscript(index)來切出( slice notation )其中的一部份的,其語法為 ""。
>>> word[4]
'A'
>>> word[0:2]
'He'
>>> word[2:4]
'lp'
不過 我在打 word[4]字串時 出現
>>> word[4]
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
word[4]
NameError: name 'word' is not definedx
我一直搞不懂這哪裡出現問題
不好意思 新手上路 很笨的
順便再問一個問題
python shell 跟 python(command line)
到底有什麼不同
我只感覺前面的介面比較漂亮華麗點
先在這邊謝謝各位大大的不吝指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.127.98.225
推
05/03 13:35, , 1F
05/03 13:35, 1F
→
05/04 02:18, , 2F
05/04 02:18, 2F
Python 近期熱門文章
PTT數位生活區 即時熱門文章