將 Python string 轉換爲 float 的方法

在Python中,咱們可使用float()將String轉換爲float。html num = "3.1415" print(num) print(type(num)) # str pi = float(num) # convert str to float print(pi) print(type(pi)) # float 輸出量python 3.1415 <class 'str'>
相關文章
相關標籤/搜索