python基本輸入輸出《二》

2021-10-23 08:06:14 字數 1243 閱讀 6956

python中不用標點,但是對各種縮排有嚴格的要求。單行注釋為「#」,多行注釋為三個單引號或者三個雙引號。

輸入為input

輸出為print

注:input 接收的所有資料都是字串,如果要做數字操作,需要進行型別轉換

str(資料)把其他型別轉化為字元型

int(資料)把其他型別轉化為整型

input 接收的所有資料都是字串,如果要做數字操作,需要進行型別轉換

##輸出

print

("hellow python!"

)

hellow python!
#單行注釋

#print("這個是單行注釋")

#多行注釋

'''print("hellow python!")

print("這個是多行注釋")

'''

'print("hellow python!")\nprint("這個是多行注釋")\n'
#獲取使用者輸入 #input 接收的所有資料都是字串,如果要做數字操作,需要進行型別轉換

user_name =

input

("請輸入的您的名字!"

)print

(user_name)

請輸入的您的名字!python

python

#input 接收的所有資料都是字串,如果要做數字操作,需要進行型別轉換

user_height =

input

("please input your height !/m"

)user_weight =

input

("please input your weight !/kg"

)bmi =

float

(user_weight)/(

float

(user_height)**2

)print

("your bmi is"

,bmi)

please input your height !/m1.77

please input your weight !/kg75

your bmi is 23.93948099205209

Python 基本輸入輸出

1.輸出 print hello,world python3中print需要加 print hello,world 多個字串之間用 逗號連線 print hello world 且遇到逗號會輸出乙個空格。2.注釋 python中用 注釋 print hello 3.變數 python中定義變數時不需...

python的基本輸入輸出

python的輸入輸出 輸入 input raw input 1.input 用於收集數字輸入 a input input a input a 2 a 可以輸入乙個變數 a input inputa input a a a 無法接收字元 a input input a input a b trace...

Python基本語法 輸入輸出

這是為學爬蟲學習的最基本的一些語法知識,實用至上,沒有對c 那麼深入。python確實挺.簡單的,不是難度方面。使用print 直接輸出即可 標準輸出字串 print hello,world 輸出變數 a 10 是的你沒有看錯,不需要指定資料型別 print a 中間使用逗號間隔開即可 print ...