元哥3天學Python--Day1

1. Interactive Shell

terminal$ python3
>>>

2. Execute .py Script

python fileName.py

Python is both an interpreted and a compiled language.

Python會自動檢查工作目錄的寫權限,如果沒有寫權限,那么編譯的代碼只會在程序執行的時候產生,程序退出,編譯的代碼就會被消除(相當于直接interpret而“未compile”)。如果有寫權限,那么編譯的代碼就會被存在.pyc文件中。

編譯的代碼由PVM執行。

Compiler: to transform source code into executable program

Interpreter: (1) execute the source code directly or (2) translates the source code in a first step into a more efficient representation and executes this code

3. Python structures by colons and indentation

從語法上保證了程序的易讀性

4. Variables

  1. Numbers

Integer, Floating, Complex

  • There is no "long int" in Python3 anymore, Integers in Python3 can be of unlimited size.
  • true div: /; floor div: //
  1. String
  • All strings in Python 3 are sequences of "pure" Unicode characters
  • ASCII: 128 characters
  • Unicode: four bytes are possible per character
  • Immutable

  • 比較

  • is 比地址;==比內容
  • 一個奇怪之處:
"Hi" is "Hi" == true 
"Hi!" is "Hi!" == False //含特殊字符

5. Operators

10 / 3 == 3.3333333333333335
10 // 3 == 3
10.0 // 3 == 3.0
10**3 == 1000
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 本節內容 Python介紹 發展史 Python 2 or 3? 安裝 Hello World程序 變量 用戶輸入...
    小小不懂11閱讀 3,442評論 2 30
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 172,846評論 25 708
  • Python的開發跟其他的一些語言是有很大不同的. 她和Ruby, Perl一樣都是解釋型語言,所以開發者能夠交互...
    周筱魯閱讀 64,878評論 0 10
  • 想你了,寶寶!
    冷雨葉閱讀 258評論 0 0
  • 昨兒夜班準備急診剖宮產,一名產婦宮口開大七八公分,胎頭近2個小時不下降,持續性枕后位,手轉抬頭失敗。產婦是一...
    王維vivian閱讀 235評論 0 2