python基礎輸入輸出

2021-09-24 13:41:26 字數 364 閱讀 9916

輸出:

`print()//加上『字串就可以輸出

print () // 函式也可以接受多個字串,用逗號「,」隔開,結果 ,會變成空格

print()//函式中可以直接進行簡單的數**算

print(『字串』 輸出變數 +… +…)表示拼接 +兩邊的變數型別必須保持一致

格式化輸出:

print(『字串%s,…%s,…%s』 % (對應佔位符的內容)) %s佔位符–str強制轉換的簡寫

%d --int型強制轉換的簡寫。佔位符方法可以解決混合輸出的問題

輸入:input()函式為python輸入函式

變數=input()可以進行輸入

input(『注釋:』 )

python基礎 輸入輸出

input print 知識點 1.input預設接收使用者輸入內容為字串型別 2.print直接輸出字串內容 card id input 請輸入學號 pwd input 請輸入密碼 print card id print type card id print pwd 1.print列印字串 pri...

Python基礎 輸入輸出

基本格式 常用格式化字元 含義 s 字串 d 有符號十進位制的整數,06d 輸出的整數顯示位數,不足的地方使用0補全 f浮點數 2f表示顯示小數點的後兩位 輸出 變數輸出例項需求 定義整數變數 student no,輸出 我的學號是 000001 student no 1 print 學號是 06d...

Python基礎 輸入輸出

輸出 print 如果要在一行中輸出多個值,那麼輸出的n個值分別使用逗號隔開 例如 print val1,val2 輸入 raw input some description python 2.7語法 input some description python 3.x語法 輸入密碼 先導入getpa...