>>
>
import keyword
>>
>
print
(keyword.kwlist)
['false'
,'none'
,'true'
,'and'
,'as'
,'assert'
,'async'
,'await'
,'break'
,'class'
,'continue'
,'def'
,'del'
,'elif'
,'else'
,'except'
,'finally'
,'for'
,'from'
,'global'
,'if'
,'import'
,'in'
,'is'
,'lambda'
,'nonlocal'
,'not'
,'or'
,'pass'
,'raise'
,'return'
,'try'
,'while'
,'with'
,'yield'
]
2、系統內建的模組名、型別名或函式名以及已導 入的模組名及其成員名作變數名
>>
>
dir(__builtins__)
['arithmeticerror'
,'assertionerror'
,'attributeerror'
,'baseexception'
,'blockingioerror'
,'brokenpipeerror'
,'buffererror'
,'byteswarning'
,'childprocesserror'
,'connectionabortederror'
,'connectionerror'
,'connectionrefusederror'
,'connectionreseterror'
,'deprecationwarning'
,'eoferror'
,'ellipsis'
,'environmenterror'
,'exception'
,'false'
,'fileexistserror'
,'filenotfounderror'
,'floatingpointerror'
,'futurewarning'
,'generatorexit'
,'ioerror'
,'importerror'
,'importwarning'
,'indentationerror'
,'indexerror'
,'interruptederror'
,'isadirectoryerror'
,'keyerror'
,'keyboardinterrupt'
,'lookuperror'
,'memoryerror'
,'modulenotfounderror'
,'nameerror'
,'none'
,'notadirectoryerror'
,'notimplemented'
,'notimplementederror'
,'oserror'
,'overflowerror'
,'pendingdeprecationwarning'
,'permissionerror'
,'processlookuperror'
,'recursionerror'
,'referenceerror'
,'resourcewarning'
,'runtimeerror'
,'runtimewarning'
,'stopasynciteration'
,'stopiteration'
,'syntaxerror'
,'syntaxwarning'
,'systemerror'
,'systemexit'
,'taberror'
,'timeouterror'
,'true'
,'typeerror'
,'unboundlocalerror'
,'unicodedecodeerror'
,'unicodeencodeerror'
,'unicodeerror'
,'unicodetranslateerror'
,'unicodewarning'
,'userwarning'
,'valueerror'
,'warning'
,'windowserror'
,'zerodivisionerror'
,'__build_class__'
,'__debug__'
,'__doc__'
,'__import__'
,'__loader__'
,'__name__'
,'__package__'
,'__spec__'
,'abs'
,'all'
,'any'
,'ascii'
,'bin'
,'bool'
,'breakpoint'
,'bytearray'
,'bytes'
,'callable'
,'chr'
,'classmethod'
,'compile'
,'complex',,
'credits'
,'delattr'
,'dict'
,'dir'
,'divmod'
,'enumerate'
,'eval'
,'exec'
,'exit'
,'filter'
,'float'
,'format'
,'frozenset'
,'getattr'
,'globals'
,'hasattr'
,'hash'
,'help'
,'hex'
,'id'
,'input'
,'int'
,'isinstance'
,'issubclass'
,'iter'
,'len'
,'license'
,'list'
,'locals'
,'map'
,'max'
,'memoryview'
,'min'
,'next'
,'object'
,'oct'
,'open'
,'ord'
,'pow'
,'print'
,'property'
,'quit'
,'range'
,'repr'
,'reversed'
,'round'
,'set'
,'setattr'
,'slice'
,'sorted'
,'staticmethod'
,'str'
,'sum'
,'super'
,'tuple'
,'type'
,'vars'
,'zip'
]
3、複數
>>
> c =5+
6j>>
> c.real
5.0>>
> c.imag
6.0
>>
> c.conjugate(
)#返回共軛複數(5
-6j)
4、字串格式化(不明白什麼意思)
>>
> a =
3.1485
>>
>
"%7.3f"
% a#向右對齊,保留三位小數
' 3.148'
>>
>
"%d is %c"%(
65,65)
'65 is a'
>>
>
"many name is %s and my age is %d"%(
'wei',20
)'many name is wei and my age is 20'
5、逗號在python中僅起到分隔作用
>>
>
'a'in
'b',
'a'(
false
,'a'
)>>
>
'a'in
('b'
,'a'
)true
>>
> x =3,
5>>
> x(3
,5)>>
>3==
3,5(
true,5
)
python學習日誌
1 python中range xrange 和np.arange 區別 range 多用於迴圈,返回乙個range物件,若想要返回乙個list則前面加上list轉換 arange 是numpy中的函式,np.range 返回乙個array型別的物件,可以使用小數步長 xrange 返回xrange ...
Python學習日誌
元組不可修改,但是可以給儲存元組的變數賦值。現在每學乙個東西就會莫名的拿去和之前學過的東西做一比較,python是真的太舒服了。當然寫for or if 都是要記得後面的 而且也可以進行級聯,只不過是if,elfe,else。還可以用in來判斷某個元素在沒有某個列表裡面。字典是一系列鍵值對,新增起來...
python 學習日誌
1 pip is already installed if you re using python 2 2.7.9 or python 3 3.4 binaries downloaded from python.org,but you ll need to upgrade pip 2 upgradi...