返回列表 發帖

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

語法
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)+"!!!")
複製代碼
Spyder 環境下常用快捷建

Ctrl+1    單行註解  
Tab    簡易智慧輸入 (輸入部分文字後按 Tab 鍵)
Ctrl+Alt+向下方向鍵    向下做單行複製
Ctrl+D    刪除單行
Ctrl+Z    回到上一步
F5    執行程式

  1. a=12122
  2. b="hello"
  3. print("sssssss")
  4. print(a,b,sep="#")
  5. print(str(a)+b)
複製代碼

TOP

回復 1# 鄭繼威
  1. a="hello"
  2. b="apple"
  3. c=0
  4. d=3.14
  5. print("apple")
  6. print("123456"+str(a)+b)
  7. print(a,c,end="1111\n")
  8. print(a,b,sep="#*#*")
  9. print(d,a,sep="+-+-",end=b)
  10. print()
  11. print(a,b,c,d,sep="$")      
複製代碼

TOP

  1. a="Hi"
  2. b="Hello"
  3. c=123456789
  4. print(a,b,"\n",str(c),sep="  ")
複製代碼

TOP

a=5
k=sm-3
print("scscs")
print(a,"pythoon",b)
print(v,s,sep="!!!@#$%^")
print(int(c)+k)

TOP

a=1
print("Brian")
print("a,wilson,b")

TOP

  1. a = "apple"
  2. b = "bear"
  3. c = 1048576
  4. d = 262144
  5. e = 524288
  6. cd = c*d
  7. cde = cd*e
  8. C = c*c*c
  9. print(a+str(c))
  10. print(a,b)
  11. print(a,b,c)
  12. print(a+b+str(c),end='!!!')
  13. print(a,b,c,sep='123')
  14. print(d+e)
  15. print(c*d)
  16. print(a,b,str(c),str(d),str(e),str(cd),sep='  ')
  17. print(str(c)+str(d)+str(e)+str(cd)+str(cde)+str(cd*cde))
  18. print(C*c)
複製代碼

TOP

a=5
b=3
print("scscs")
print(a,"pythoon",b)
print(a,b,sep="!!!@#$%^")
print(int(a)+b)

TOP

a="hi"
b="hello"
print(a,"zzzzz",b,sep="~~")
print(a,"zzzzz",b,sep="~~",end="~~\n")

TOP

a=11113
print("a=11113")
print("wilson")
print("jobe")
print("11111111111111111111111111111111111111111111111111111111111")

TOP

name="劉恆"
age=12
print("name+age")

TOP

本帖最後由 高士涵 於 2023-8-2 10:28 編輯
  1. a=1
  2. b=2
  3. print(a)
  4. print(str(a)+"s"+str(b))
  5. print(a,b,sep="pls")
  6. print(str(a),"jkl",str(b),sep="x")
  7. print(a,b,sep="??",end="")
  8. print(str(a)+"123"+str(b))
  9. print(a)
  10. print(b)
  11. print(a)
  12. print(b)
  13. print(a)
  14. print(b)
複製代碼

TOP

  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor

  4. This is a temporary script file.
  5. """
  6. a=888
  7. b=777
  8. print(a,b,sep='')
  9. print(str(a)+str(b)+"andy")
複製代碼

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=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=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)+"!!!")
複製代碼
Attention Seeker </3

TOP

  1. a=123
  2. b=456

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

TOP

  1. a="hi"
  2. b="Sherry"
  3. c=0

  4. print(a,b+str(c))
複製代碼

TOP

  1. a=123
  2. b=789
  3. print(a,b)
  4. print(a,"OwO",b,sep="~")
  5. print("OAo",b)
  6. print(str(a)+":D"+str(b))
複製代碼

TOP

  1. a=123
  2. b=456
  3. print(a,"sss",b,sep="???")
  4. print(a,"sss",b,sep="???",end='ooo\n')
複製代碼

TOP

返回列表