天天看點

python基礎知識

  1. 使用Python(command line)即下載下傳python自帶的解釋器,請注意區分指令行模式和Python互動模式,在指令行模式下,可以執行

    python

    進入Python互動式環境,也可以執行

    python hello.py

    運作一個

    .py

    檔案,但是在Python互動式環境下,隻能輸入Python代碼執行,不能直接執行一個檔案!
  2. print輸出,列印多個變量需要加上逗号!Python提供了一個

    raw_input

    ,可以讓使用者輸入字元串,并存放到一個變量裡。列印出

    name

    變量的内容,除了直接寫

    name

    然後按回車外,還可以用

    print

    語句。
  3. name = raw_input('please enter your name: ')
    print 'hello,', name      
please enter your name: Michael
hello, Michael