2018年3月7日 星期三

Python保留字

保留字,不可以當作其他用途使用,尤其是變數名稱命名,以避免衝突。如果記不起來,Python 提供一個快速查詢指令:

〉〉〉 import keyword
〉〉〉 keyword.kwlist

['False', 'None', 'True', 'and', 'as', 'assert', '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']


2018年3月6日 星期二

Python 資料型別


Python 有內建幾種資料型別如下:


1.數字 (Number)

2.字串 (String)

3.布林值 (Boolean)

4.列表 (List)

5.元組 (Tuple)

6.字典 (Dictionary)

7.集合 (Set)

2018年3月5日 星期一

Python 內建函式




受歡迎的 Python 其內建函式如下,日後再個別範例解說: 


abs()

dict()

hex()

all()

dir()

help()

any()

divmod()

id()

ascii()

enumerate()

input()

bin()

eval()

int()

bool()

exec()

isinstance()

bytearray()

filter()

issubclass()

bytes()

float()

iter()

callable()

format()

len()

chr()

frozenset()

list()

classmethod()

getattr()

locals()

compile()

globals()

map()

complex()

hasattr()

max()

delattr()

hash()

min()

memoryview()

sorted()

next()

staticmethod()

object()

str()

oct()

sum()

ord()

open()

super()

tuple()

pow()

type()

range()

print()

vars()

__import__()

property()

zip()

repr()

setattr()

reversed()

slice()

round()

set()