ทำความรู้จักกับภาษา python (17) : การสร้างฟังก์ชันโดยมี Keyword

แชร์ความรู้ภาษา Python ไพทอน การเขียนโปรแกรมภาษาไพทอน

Moderator: mindphp, ผู้ดูแลกระดาน

anuwat somsakul
PHP Full Member
PHP Full Member
โพสต์: 44
ลงทะเบียนเมื่อ: 08/08/2018 9:49 am

Re: ทำความรู้จักกับภาษา python (17) : การสร้างฟังก์ชันโดยมี Keyword

โพสต์ที่ยังไม่ได้อ่าน โดย anuwat somsakul »

การสร้างฟังก์ชั่น ในไพทอน Python Defining function โดยมี Keyword Arguments

โค้ด: เลือกทั้งหมด

def mykey(i,phone="Phone number is not specified",email="Email is not specified"):
    print("-- ID",i)
    print("-- phone",phone)
    print("-- keyword arg email:",email,"!")

mykey('001','0485255455')
mykey(email='[email protected]',i=415525)
ผลลัพธ์
Selection_009.png
Selection_009.png (11.35 KiB) Viewed 742 times
ภาพประจำตัวสมาชิก
chatee supasand
PHP VIP Members
PHP VIP Members
โพสต์: 1666
ลงทะเบียนเมื่อ: 04/06/2019 10:06 am

Re: ทำความรู้จักกับภาษา python (17) : การสร้างฟังก์ชันโดยมี Keyword

โพสต์ที่ยังไม่ได้อ่าน โดย chatee supasand »

ทดลองทำตามแล้ว เข้าใจง่ายมากครับ สอนได้เข้าใจมากๆ
รูปภาพ
ภาพประจำตัวสมาชิก
jirawoot
PHP VIP Members
PHP VIP Members
โพสต์: 3129
ลงทะเบียนเมื่อ: 17/06/2019 10:30 am

Re: ทำความรู้จักกับภาษา python (17) : การสร้างฟังก์ชันโดยมี Keyword

โพสต์ที่ยังไม่ได้อ่าน โดย jirawoot »

โค้ด: เลือกทั้งหมด

def mykey(i,phone='phone number is not', email='email is not'):
    print('ID = ',i)
    print('phone =',phone)
    print('email=', email)

mykey('001','0844235555')
ผลลัพธ์
Selection_018.png
Selection_018.png (7.22 KiB) Viewed 403 times
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Amazon [Bot] และบุคลทั่วไป 52