Python-程式語法 - Python註釋&基本函式

合滨發表於2024-08-18

Python註釋

以# 為行開頭為註釋

相關函式

str()     --- 傳入一個整型值,並求值為它的字串形式
Python 2.7.17 (default, Mar  8 2023, 18:40:28)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> str(94343)
'94343'
>>> print('I am' + str(18) + 'Years old.')
I am18Years old.
>>> print('I am' +  str(18) + 'Years old.')
I am18Years old.
>>> print('I am ' + str(18) + ' Years old.')
I am 18 Years old.
>>>
int()  --- 與str()將輸入值轉換為字串相反,int()函式將字串資料作為輸入,輸出為整數!
>>> int(1234)
1234
>>> int(34)
34
>>> int(-9990)
-9990
float()  --- 將輸入字串求取浮點數形式的值
>>> float(1099)
1099.0
>>> float(-999)
-999.0

相關文章