Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python
Python
  1. Permutation และ Combination ใน Python (itertools)

    Python มี Built-in Package itertools สำหรับหา Permutation และ Combination ของ Sequence ได้อย่างง่ายดาย อัลกอริทึมพื้นฐาน Import itertools ใช้ permutations() หรือ combinations() กับ Sequence กำหนดความยาว (r) ได้ (Optional) Iterate หรือแปลงเป็น List เพื่อดูผลลัพธ์ Permutation (ลำดับสำคัญ) จัดเรียง

  2. Object-Oriented Programming ใน Python (OOP)

    Python เป็นภาษา Object-Oriented ตั้งแต่แรกเริ่ม Class และ Object เป็นสอง Building Blocks หลักของ OOP กำหนด Class ใน Python # Class พื้นฐาน class Vehicle: pass # Empty Class # สร้าง Object (Instantiate) v = Vehicle() print(v) # เพิ่ม Method ใน Class class Vehicle: def car(self):

  3. OpenCV Python Program: Blur รูปภาพ (Gaussian Blur)

    OpenCV เป็นหนึ่งในไลบรารี่ที่ดีที่สุดสำหรับ Image Processing ใน Python รูปภาพมักมี Noise จากแหล่งที่มา (Camera Sensor) OpenCV มีเทคนิค Image Smoothing หรือ Blurring หลายแบบ หนึ่งในวิธีทั่วไปคือใช้ Gaussian Filter ขอบคมจะถูดลับในขณะที่ลด Blurring เกินไป Syntax cv2.GaussianBlur(src, ksize, sigmaX[, d

  4. Mouse และ Keyboard Automation ใน Python (pyautogui)

    ใช้โมดูล pyautogui สำหรับควบคุม Mouse และ Keyboard อัตโนมัติ Cross-platform GUI Automation ติดตั้ง pip install pyautogui ควบคุม Mouse import pyautogui # ขนาดหน้าจอ width, height = pyautogui.size() print(fScreen: {width}x{height}) # ตำแหน่งปัจจุบันของเมาส์ print(pyautogui.position()) # ย้ายเมาส์

  5. การแพ็กเกจและเผยแพร่ Python Code (Packaging & Publishing)

    Python มีวิธีง่ายๆ ในการสร้างและเผยแพร่ Package เครื่องมือ Package Management Pip: ตัวจัดการแพ็กเกจหลัก กำจัดการติดตั้ง Manual จัดการรายการแพ็กเกจและเวอร์ชัน Python Package Index (PyPI): Public Repository ติดตั้งได้ด้วย pip install package_name ขั้นตอนการสร้างและเผยแพร่ Package Step 1: เตรียม P

  6. Line Detection ใน Python ด้วย OpenCV (Hough Transform)

    เรียนรู้การตรวจจับเส้นตรงในรูปภาพด้วยเทคนิค Hough Transform ผ่าน OpenCV Hough Transform คืออะไร? Hough Transform เป็น Feature Extraction Method สำหรับตรวจจับรูปทรงง่ายๆ ที่สามารถแทนได้ในรูปแบบทางคณิตศาสตร์ สามารถตรวจจับได้แม้รูปทรงจะแตกหรือบิดเบือนเล็กน้อย Simple Shape คือรูปทรงที่แทนได้ด้วยพารามิ

  7. NZEC Error ใน Python คืออะไร? (Non-Zero Exit Code)

    NZEC คือ Non-Zero Exit Code Exit Code คือรหัส (ตัวเลข) ที่โปรแกรมคืนให้ Operating System เมื่อจบการทำงาน: Exit Code 0: จบสำเร็จ (Successful Termination) Non-Zero Exit Code: จบล้มเหลวเนื่องจาก Error (Failed Termination) เนื่องจาก Python รองรับ Exception Handling เราสามารถใช้ try-except จับ Error น

  8. Short-Circuit Evaluation ใน Python (เทคนิคการประเมินแบบลัดวงจร)

    ข้อผิดพลาดทั่วไปของมือใหม่คือเข้าใจผิดการทำงานของ Boolean Operators (and, or) ซึ่งมาจากวิธีที่ Python Interpreter อ่านนิพจน์เหล่านี้ ตัวอย่างที่ทำให้สับสน >>> x == (x or y) True >>> y == (x or y) False >>> x == (x and y) False >>> y == (x and y) True ดูเหมือน an

  9. การทำงานกับรูปภาพใน Python ด้วย Pillow (PIL)

    Pillow เป็นไลบรารี่ยอดนิยมและเป็น Default สำหรับ Image Processing ใน Python เป็นเวอร์ชันอัปเดตของ PIL (Python Image Library) รองรับการจัดการรูปภาพตั้งแต่พื้นฐานถึงขั้นสูง เป็นฐานของ Image Support ใน SciPy และ Matplotlib ติดตั้ง Pillow pip install pillow โหลดและแสดงรูปภาพ from PIL import Image # โ

  10. Python Data Analysis และ Visualization ด้วย Pandas และ Matplotlib

    Pandas เป็นไลบรารี่ยอดนิยมสำหรับ Data Science และ Analytics ใช้สำหรับ Data Manipulation, Analysis และ Cleaning เป็น High-level Abstraction อยู่เหนือ NumPy ที่เขียนด้วย C เนื้อหานี้ครอบคลุมสิ่งสำคัญที่ Analyst/Data Scientist ควรรู้ ติดตั้งไลบรารี่ pip install pandas matplotlib DataFrame และ Series

  11. C-style Parser สำหรับ Command Line Options ใน Python (getopt)

    โมดูล sys ของ Python ให้เข้าถึง Command-line Arguments ผ่าน sys.argv ซึ่ง sys.argv[0] คือชื่อสคริปต์ โมดูล getopt มีฟังก์ชัน Parse Command Line Arguments ใน sys.argv รองรับ Convention เดียวกับ Unix getopt() รวมถึงความหมายพิเศษของ - และ -- API ออกแบบให้คุ้นเคยกับผู้ใช้ C getopt() getopt(args, short

  12. เข้าถึงข้อมูลระบุตัวตนของ Platform ใน Python (โมดูล platform)

    ฟังก์ชันในโมดูล platform ช่วยสำรวจ Hardware, Operating System และข้อมูลเวอร์ชัน Interpreter ของ Platform ที่อยู่เบื้องหลัง ฟังก์ชันหลัก ฟังก์ชันคำอธิบายตัวอย่างผลลัพธ์ architecture()สอบถามข้อมูล Architecture ของ Executable (Default: Python Interpreter)(64bit, ) machine()คืน Machine Type เช่น x8

  13. zipapp - จัดการ Executable Python Zip Archives

    โมดูล zipapp ถูกเพิ่มใน Python Standard Library ตั้งแต่เวอร์ชัน 3.5 ใช้จัดการการสร้างไฟล์ Zip ที่มีโค้ด Python ซึ่งสามารถรันได้โดยตรงด้วย Python Interpreter โมดูลนี้มีทั้ง Command-Line Interface และ Programming Interface การใช้งานผ่าน Command Line ต้องมีโฟลเดอร์ที่มีโมดูลพร้อมฟังก์ชัน main() python

  14. Common String Operations ใน Python (โมดูล string)

    โมดูล string ใน Standard Library ของ Python มี Constants, Classes และ Helper Function capwords() ที่มีประโยชน์ Constants Constantคำอธิบาย ascii_lettersรวม lowercase และ uppercase ascii_lowercaseตัวอักษรพิมพ์เล็ก abcdefghijklmnopqrstuvwxyz ascii_uppercaseตัวอักษรพิมพ์ใหญ่ ABCDEFGHIJKLMNOPQRSTUVW

  15. FTP Protocol Client ใน Python (ftplib)

    คลาส FTP ในโมดูล ftplib นำ Client Side ของ FTP Protocol ไปใช้งาน เพื่อสร้างการเชื่อมต่อกับ FTP Server ให้สร้าง FTP Object con = FTP(hostname) เมธอดสำคัญของ FTP Class เมธอดคำอธิบาย connect()เชื่อมต่อกับ Host และ Port ที่กำหนด (Default Port 21) getwelcome()คืน Welcome Message จาก Server login(us

  16. POP3 Protocol Client ใน Python (poplib)

    โมดูล poplib จาก Standard Library ของ Python กำหนดคลาส POP3 และ POP3_SSL คลาส POP3 บรรจุการเชื่อมต่อกับ POP3 Server และนำโปรโตคอลตาม RFC 1939 ไปใช้งาน คลาส POP3_SSL รองรับ POP3 Server ที่ใช้ SSL เป็นโปรโตคอลชั้นล่าง โปรโตคอล POP3 ล้าสมัยแล้ว เนื่องจากคุณภาพการนำไปใช้ของ POP3 Server ค่อนข้างแย่ หาก

  17. Package Extension Utility ใน Python (pkgutil)

    เมื่อคุณต้องการเพิ่ม Module Search Path สำหรับ Package เฉพาะ และทำงานกับ Resources ที่อยู่ใน Package คุณต้องใช้โมดูล pkgutil จาก Python Library โมดูลนี้มีฟังก์ชันสำหรับเปลี่ยนกฎการ Import สำหรับ Python Packages และสามารถโหลด Non-code Resources จากไฟล์ที่กระจายอยู่ใน Package ได้ extend_path(path, na

  18. Interpreter Base Classes ใน Python

    โหมดโต้ตอบ (Interactive Mode) ของ Python ทำงานหลักการ REPL (Read - Evaluate - Print - Loop) โมดูล code ใน Standard Library ของ Python มีคลาสและฟังก์ชันสะดวกสำหรับตั้งค่าสภาพแวดล้อม REPL จากในสคริปต์ Python คลาสสองตัวในโมดูล code InteractiveInterpreter: จัดการการแยกวิเคราะห์ (parsing) และสถานะของ I

  19. Python มี Inheritance กี่ประเภท?

    Inheritance (การสืบทอด) เป็นแนวคิดที่คลาสหนึ่งเข้าถึงเมธอดและพรอพเพอร์ตี้ของอีกคลาสหนึ่งได้ Parent Class คือคลาสที่ถูกสืบทอด เรียกอีกอย่างว่า Base Class Child Class คือคลาสที่สืบทอดมาจากอีกคลาส เรียกอีกอย่างว่า Derived Class ใน Python มี Inheritance 2 ประเภทหลัก: Multiple Inheritance (การสืบทอด

  20. Python รองรับ Multiple Inheritance หรือไม่?

    ใช่ Python รองรับ Multiple Inheritance เช่นเดียวกับ C++ คลาสหนึ่งสามารถสืบทอดมาจาก Base Class หลายตัวใน Python เรียกว่า Multiple Inheritance ใน Multiple Inheritance คุณสมบัติของ Base Class ทั้งหมดจะถูกสืบทอดไปยัง Derived Class ตัวอย่าง class Animal: def eat(self): print(It eats insect

Total 9001 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:94/451  20-คอมพิวเตอร์/Page Goto:1 88 89 90 91 92 93 94 95 96 97 98 99 100