日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python字符串转浮点数_Python | 打印不同的值(整数,浮点数,字符串,布尔值)...

發布時間:2025/3/11 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python字符串转浮点数_Python | 打印不同的值(整数,浮点数,字符串,布尔值)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python字符串轉浮點數

In the given example, we are printing different values like integer, float, string and Boolean using print() method in python.

在給定的示例中,我們使用python中的print()方法打印不同的值,例如整數,浮點數,字符串和布爾值。

Program:

程序:

# printing integer value print(12) # printing float value print(12.56) # printing string value print("Hello") # printing boolean value print(True)

Output

輸出量

12 12.56 Hello True

Arithmetic operations inside the print() on values

在print()中對值進行算術運算

# adding and printing integer value print(12+30) # adding and printing float value print(12.56+12.45) # adding and printing string value print("Hello"+"World") # adding and printing boolean value print(True+False)

Output

輸出量

42 25.009999999999998 HelloWorld 1

Printing different types of variables

打印不同類型的變量

# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing all variables print(a) print(b) print(c) print(d)

Output

輸出量

12 12.56 Hello True

Printing different types of variables along with the messages

打印不同類型的變量以及消息

# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing values with messages print("Integer\t:",a) print("Float\t:",b) print("String\t:",c) print("Boolean\t:",d)

Output

輸出量

Integer : 12 Float : 12.56 String : Hello Boolean : True

Printing different types of variables with messages and converting them to string using "str()" function

使用消息打印不同類型的變量,并使用“ str()”函數將其轉換為字符串

# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing values with messages print("Integer\t:"+str(a)) print("Float\t:"+str(b)) print("String\t:"+str(c)) print("Boolean\t:"+str(d))

Output

輸出量

Integer :12 Float :12.56 String :Hello Boolean :True

翻譯自: https://www.includehelp.com/python/printing-different-values-integer-float-string-boolean.aspx

python字符串轉浮點數

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的python字符串转浮点数_Python | 打印不同的值(整数,浮点数,字符串,布尔值)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。