python輸入列印

2021-10-03 00:23:23 字數 1670 閱讀 6741

#輸入列印1

name =

input

("姓名:"

)#***

age =

input

("年齡:"

)#30

job =

input

("工作:"

)#業務員

salary =

input

("薪水:"

)#2000

info =

'''-----'''

+ name +

''' 的資料-----

姓名:'''

+ name +

'''年齡:'''

+ age +

'''工作:'''

+ job +

'''薪水:'''

+ salary +

''''''

print

(info)

#輸出結果1--

---*** 的資料---

--姓名:***

年齡:30

工作:業務員

薪水:2000

#輸入列印2

name =

input

("姓名:"

)age =

input

("年齡:"

)job=

input

("工作:"

)salary =

input

("薪水:"

)info =

'''-----%s 的資料-----

姓名:%s

年齡:%s

工作:%s

薪水:%s

'''%

(name,name,age,job,salary)

print

(info)

#輸出結果2--

---*** 的資料---

--姓名:***

年齡:30

工作:業務員

薪水:2000

#輸入列印3

'''python 預設所有輸入都是字元,如果要設定為數字,一定要轉換。

type()字元型別

int()轉換為數字

'''name =

input

("姓名:"

)age =

int(

input

("年齡:"))

print

(type

(age)

)job=

input

("工作:"

)salary =

input

("薪水:"

)info =

'''----- 的資料-----

姓名:年齡:

工作:薪水:

'''.

format

(name,age,job,salary)

print

(info)

#輸出結果3--

---*** 的資料---

--姓名:***

年齡:30

工作:業務員

薪水:2000

python 輸入和列印輸出

方式一 直接等待從鍵盤上輸入資訊,然後回車 name input 方式二 先輸出一些提示資訊 name input please enter your name 方式一 單字串 print hello,world 方式二 多字串,遇到逗號 會輸出乙個空格 print the quick brown ...

python 列印 輸入語句的使用

print hello world print hello 3 輸出3個hello print hello world 中間乙個空格分隔 print 多行語句 分割 print 換行 n 符 換行符print 第一列 t第二列 print 不換 end print 行 print a b forma...

輸入列印語句列印引用的問題

在學習object類的時候,我們這麼來用他object st new student 當呼叫列印語句的時候,即system.out.println st 列印的效果卻和呼叫tostring 方法的效果是一樣的,即system.out.println st.tostring 這是怎麼回事了,讓我們跟蹤...