如果熟其他計算機語言,可能會習慣於每行以分號結束。python則不同,一行就是一行,不管多少。
>>> from __future__ import division
>>> 1/2
0.51.4.1 長整型數:
1.6 語句
1.7 獲取使用者輸入:
>>> input("the meaning of life:")
the meaning of life:1122
1122
>>>
>>> x=input("x值是: ")
x值是: 34
>>> print x
34if 7 > 6:
print '7>6';
>>> if 7 > 6:
... print '7>6';
...7>6
1.8 函式:
1.9 模組:
檢視安裝的py模板:
就是在python環境中輸入:
help(『modules』) 就能列出所有已經安裝的模組了。
>>> help()
help> modules
稍等一會後,就會列出所有的模組
import math
math.floor(32.9)
用import 匯入了模組,然後安裝"模組.函式"的格式使用這個模組的函式
在確定自己不會匯入多個同步函式(從不同的模組匯入)的情況下,你可能不希望在每次呼叫函式的時候,
都要寫上模組的名字。那麼,可以使用import命令的另外一種形式:
1.10.1 通過命令提示符執行python指令碼:
1.11.4 input 和raw_input 的比較:
name=input("what is your name?")
print "hello,"+name+
Python第一章基礎知識
python3.x 1 沒有了raw input,只有input 2 print是函式,要使用print 而不是print 3 所有的字串都是unicode字串 原始字串可以簡化反斜線的使用,以r開頭,在原始字串的結尾不能使用反斜線 第一章基礎知識 函式abs cmath.sqrt 返回平方根,也可...
Python第一章 基礎知識
加法 print 2 2 浮點數 print 1 2 丟棄小數部分,向下圓整 print 1 2 print 5.0 2.4 取餘x y 即為 x x y y print 10 3 print 2.75 0.5 print 10 3 print 10 3 乘方 print 2 3 print 3 2...
第一章 基礎知識
組合語言 第一章 基礎知識 1.3組合語言的組成 組合語言有以下3 類組成 1.彙編指令 機器碼助記符 2.偽指令 由編譯器執行 3.其他符號 右邊一起識別 組合語言的核心是彙編指令,他決定了組合語言的特性 1.4 儲存器 指令和資料在儲存器中存放,也就是平時說的記憶體 磁碟不同於記憶體,磁碟的資料...