首頁>Club>
139
回覆列表
  • 1 # 菠蘿小仙女南巷薄荷微

    1、說明:

      python輸出時不換行,python版本不同使用方式不同:python2.x使用print"輸出內容",加一個空格即可;python3.x版本使用print("輸出內容",end="")這種方式。

      2、程式碼示例:

      python2.x

      print"不換行",

      print"換行"

      python3.x

      print("不換行",end="")

      print("換行")

      執行結果:

      python2.x

      不換行換行

      python3.x

      不換行換行

      3、函式說明:

      python2.x

      print

      一個"\n"字元結尾寫的,除非"print"宣告以逗號結束。這是如果該語句的唯一操作只包含關鍵字"print"。

      python3.x

      print(...)

      print(value,...,sep="",end="\n",file=sys.stdout,flush=False)

      end:字串的最後一個值後追加,預設為新行。

  • 中秋節和大豐收的關聯?
  • 金立手機顯示充電中卻充不進電怎麼辦?