返回列表 發帖

變數宣告與基本輸出 (一)

語法
print(項目1 [,項目2 ,... (,sep=分隔字元,end=結束字
元]))
print()顯示的字串可以使用+ 進行組合,但不同型別
要先轉為文字。

  1. a=123
  2. b=456
  3. print(a,"python",b)
  4. print(a,"python",b,sep="~")
  5. print(a,"python",b,sep="~",end="!!!\n")
  6. print(str(a)+"~python~"+str(b)+"!!!")
複製代碼

  1. 987 python 321
  2. 987~python~321
  3. 987~pythoend~321!!!
  4. 987~python~321+!!!
複製代碼

TOP

  1. 123 python 456
  2. 123~python~456
  3. 123~python~456!!!
  4. 123~python~456!!!
複製代碼

TOP

本帖最後由 簡宗漢 於 2022-8-18 11:28 編輯
  1. p=94
  2. b=10000000
  3. c=789
  4. d=8788

  5. e=1000000
  6. f=str(b+e)
  7. g=12435679810111213141516171819
  8. h=2435679810111213141516171819
  9. i=g-h
  10. print(str(b)+"abcdefg",str(a+b),f,sep="lol"+str(a+b+c+d)+f+str(i))
  11. print(str(b)+"abcdefg",str(a+b),f,sep="lol"+str(a+b+c+d)+f+str(i))
  12. print(str(b)+"abcdefg",str(a+b),f,sep="lol"+str(a+b+c+d)+f+str(i))
  13. print(str(b)+"abcdefg",str(a+b),f,sel",end="/**/\\/\\\n")
複製代碼

TOP

本帖最後由 吳俊頡 於 2022-8-18 11:30 編輯
  1. a=123
  2. b=456
  3. print(a,"turtle",b)
  4. print(a,"turtle",b,sep="~")
  5. print(a,"turtle",b,sep="~",end="!!!\n")
  6. print(str(a)+"~turtle~"+str(b)+"???")
複製代碼

TOP

  1. a=111112113
  2. b=114115116
  3. print(a,"python",b)
  4. print(a,"python",b)
  5. print(a,"python",b,sep="~")
  6. print(str(a)+"~python~"+str(b)+"!!!\n")
複製代碼

TOP

  1. a=123
  2. b=456
  3. print(a,"python",b)
  4. print(a,"python",b,sep="~")
  5. print(a,"python",b,sep="~",end="!!!\n")
  6. print(str(a)+"~python~"+str(b)+"!!!")
複製代碼

TOP

  1. a=12345
  2. b=67890
  3. print(a,"python",b)
  4. print(a,"python",b,sep="~")
  5. print(a,"python",b,sep="~",end="!!!\n")
  6. print(str(a)+"~python~"+str(b)+"!!!")
複製代碼

TOP

  1. a=123
  2. b=456

  3. print(a,"python",b)
  4. print(a,"python",b,sep="~")
  5. print(a,"python",b,sep="~",end="!!!\n")
  6. print(str(a)+"~python~"+str(b),end="!!!")
複製代碼

TOP

返回列表