1. 程式人生 > >python基礎--函式1(abs,max,min,int,str,float,bool,bytes)

python基礎--函式1(abs,max,min,int,str,float,bool,bytes)

測試程式碼:

#abs,max,min,int,str,float,bool,bytes >>> abs(-10) 10 >>> max(1,6,3) 6 >>> min(1,6,3) 1 >>> int(r) Traceback (most recent call last):   File "<stdin>", line 1, in <module> NameError: name 'r' is not defined >>> int(10) 10 >>> str(q) Traceback (most recent call last):   File "<stdin>", line 1, in <module> NameError: name 'q' is not defined >>> str(99) '99' >>> float(10.1) 10.1 >>> bool(5) True >>> bool(-1) True >>> bool(5>5) False >>> bytes(qwe) Traceback (most recent call last):   File "<stdin>", line 1, in <module> NameError: name 'qwe' is not defined >>> bytes('qw') Traceback (most recent call last):   File "<stdin>", line 1, in <module> TypeError: string argument without an encoding >>> bytes('qq', encoding='utf-8') b'qq' >>>     

說明:

1. 如果執行函式錯誤,請根據錯誤資訊進行排查 。