Python使用者互動程式

來源:互聯網
上載者:User

標籤:參數   log   family   類型   orm   job   程式   定義   bsp   

#進行互動,row_input在python3裡面等同於input
1 username = input("username:")2 job = input("your job:")3 age = int(input("your age:")) #string轉換成int

 
#字串拼接↓
 1 info = ‘‘‘ 2 ------now-------------- 3 Name:‘‘‘+ username +‘‘‘ 4 job:‘‘‘ + job + ‘‘‘ 5 ‘‘‘ 6 #---------------------- 7 info_2 = ‘‘‘ 8 ------now_2-------------- 9 Name:%s         #字串string10 job:%s11 age:%d          #只能是int12 ‘‘‘ % (username,job,age)13 14 info_3 =‘‘‘15 ------now_3--------------16 Name:{name_1}         17 job:{job_2}18 age:{age_3}19 ‘‘‘.format(name_1=username,job_2=job,age_3=age) #{}裡面的參數可以自己定義20 21 print(info,‘\n‘)22 print(info_2)23 print(info_3)24 #判斷類型25 print(type(age))

 

#輸出結果

 

 1 username:gdr 2 your job:it 3 your age:24 4  5 ------now-------------- 6 Name:gdr 7 job:it 8   9 10 11 ------now_2--------------12 Name:gdr         #字串string13 job:it14 age:24          #只能是int15 16 17 ------now_3--------------18 Name:gdr         19 job:it20 age:2421 22 <class ‘int‘>

 


 

 

Python使用者互動程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.