Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python
Python
  1. ตรวจสอบ UNIX Password ด้วย Python (โมดูล crypt)

    โมดูล crypt ใช้ตรวจสอบ Password แบบ UNIX ใช้ Hash Function แบบ One-way (Modified DES Algorithm) import crypt crypt.crypt(word, salt) word: Password ที่ผู้ใช้กรอก salt: Random String (2 ตัวอักษรขึ้นไป) ใช้ Perturb DES Algorithm 4096 วิธี Salt ประกอบด้วย: A-Z, a-z, 0-9, /, . คืนค่า: Hashed

  2. POSIX TTY Control ใน Python (โมดูล termios)

    โมดูล termios ให้ Interface ไปยัง POSIX TTY I/O Control ระดับต่ำ ควบคุม Terminal Attribute ทุกอย่างได้เฉพาะ UNIX import termios เมธอดหลัก termios.tcgetattr(fd) คืน List ของ Terminal Attributes: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] termios.tcsetattr(fd, when, attributes) ตั้งค่า Attr

  3. Terminal Control Functions ใน Python (โมดูล tty)

    โมดูล tty ควบคุม Terminal Mode ใน UNIX: ตั้งค่า Raw Mode และ Cbreak Mode เพื่ออ่าน Input ทันทีไม่ต้องกด Enter import tty (ต้องใช้ร่วม termios) โหมด Terminal โหมดคุณสมบัติ Raw Mode Input ส่งทันทีทุกตัวอักษร (ไม่รอ Enter) ไม่มี Line Editing (Backspace, Ctrl+U ไม่ทำงาน)

  4. Pseudo-terminal Utilities ใน Python (โมดูล pty)

    โมดูล pty จัดการ Pseudo-Terminal (PTY) ใช้เริ่ม Process ใหม่และอ่าน/เขียนผ่าน Controlling Terminal เหมาะสำหรับ Automation, Testing, Terminal Emulators ทำงานได้เฉพาะ UNIX/Linux import pty เมธอดหลัก pty.fork() Fork Process และเชื่อม Child ไปยัง PTY ใหม่ คืนค่า: (pid, fd) Child: pid=0, fd=inva

  5. fcntl และ ioctl System Calls ใน Python

    โมดูล fcntl เป็น Interface ไปยัง fcntl() และ ioctl() System Calls ของ UNIX สำหรับควบคุม File Descriptor และ I/O import fcntl เมธอดหลัก fcntl.fcntl(fd, op[, arg]) ทำ Operation บน File Descriptor fd: File Descriptor (int หรือ io.IOBase) op: Operation Code (F_GETFL, F_SETFL, F_GETFD, F_SETFD,

  6. Python Interface to Shell Pipelines (โมดูล pipes)

    โมดูล pipes ให้ Python สร้าง Shell Pipeline ได้แบบ Object-Oriented ใช้ /bin/sh ภายใน import pipes คลาส Template แทน Pipeline หนึ่ง Pipeline มีเมธอดหลัก: เมธอดคำอธิบาย reset()รีเซ็ต Template กลับสถานะเริ่มต้น clone()คัดลอก Template ใหม่เหมือนเดิม debug(flag)True = แสดงคำสั่งระหว่างรัน

  7. Resource Usage Information ใน Python (โมดูล resource)

    โมดูล resource ใช้วัดและควบคุม Resource Usage ของ Process ใน UNIX (CPU Time, Memory, File Descriptors, etc.) import resource Resource Limits (การจำกัดทรัพยากร) มี 2 ระดับ: Soft Limit: ขีดจำกัดปัจจุบัน แก้ไขได้ แต่ไม่เกิน Hard Limit Hard Limit: ขีดจำกัดสูงสุด ลดได้ แต่เพิ่มไม่ได้ (ต้อง Root)

  8. Python Interface to UNIX syslog Library

    โมดูล syslog ให้ Python เขียน Log เข้า UNIX System Logger (syslogd) ได้โดยตรง import syslog เมธอดหลัก syslog.syslog(message) / syslog.syslog(priority, message) ส่งข้อความไป System Logger พร้อม Priority Level syslog.openlog([ident[, logoption[, facility]]]) ตั้งค่า Logging Options สำหรับการเรียก

  9. Unix Filename Pattern Matching ใน Python ด้วย fnmatch

    โมดูล fnmatch ใช้จับคู่ชื่อไฟล์แบบ Unix Shell Wildcard คืนค่า True/False อยู่ใน Standard Library import fnmatch Wildcard Patterns Patternความหมาย *จับคู่อะไรก็ได้ (0 ตัวขึ้นไป) ?จับคู่ตัวอักษรเดี่ยว 1 ตัว [seq]จับคู่ตัวอักษรในชุด seq (เช่น [abc]) [!seq]จับคู่ตัวอักษรที่ ไม่อยู่ ใน seq

  10. Birthday Reminder Application ใน Python

    สร้างแอปพลิเคชันแจ้งเตือนวันเกิด: ตรวจสอบทุกวันว่ามีวันเกิดวันนี้หรือไม่ แจ้งเตือนผ่าน System Notification โครงสร้าง Lookup File ไฟล์ birth_day_lookup.txt (เก็บที่ Home Directory) 05-September John Doe 12-January Jane Smith 25-December Bob Wilson รูปแบบ: DD-MonthName FirstName LastName โค้ดหลั

  11. Speech Recognition ใน Python ด้วย Google Speech API

    Speech Recognition เป็นฟีเจอร์สำคัญสำหรับ Home Automation, AI Assistant, Voice Control ใช้ไลบรารี SpeechRecognition ร่วมกับ Google Web Speech API การติดตั้ง pip install SpeechRecognition # สำหรับ Microphone (Linux) sudo apt-get install python3-pyaudio การตั้งค่า Microphone Device Index: ระบุ

  12. คำนวณ Round Trip Time (RTT) ด้วย Python

    Round Trip Time (RTT) คือเวลาที่สัญญาณใช้ไป-กลับ: จากส่ง Request จนได้รับ Response/Acknowledgment ปัจจัยที่ส่งผลต่อ RTT Data Transfer Rate ด้าน Sender ชนิด Transmission Media (Fiber, Copper, Wireless) ระยะทางจริงระหว่าง Sender-Receiver จำนวน Node/Router ระหว่างทาง Traffic บน LAN จำนวน

  13. Erosion และ Dilation รูปภาพด้วย OpenCV ใน Python

    Morphological Operations สองตัวสำคัญใน Computer Vision: Erosion (การกัด蚀) และ Dilation (การขยาย) ใช้โมดูล OpenCV ติดตั้ง: pip install opencv-python Erosion (การกัด蚀) กัดขอบวัตถุ foreground (สีขาว) ใช้เพื่อ: กำจัด White Noise เล็กๆ แยกวัตถุที่ติดกัน ลดความหนาของวัตถุ หลักการทำงาน สร้า

  14. ChainMap ใน Python: รวมหลาย Dictionary เป็นมุมมองเดียว

    ChainMap รวมหลาย Dictionary ให้ดูเหมือน Dictionary เดียว โดยไม่ต้อง Merge จริง อยู่ในโมดูล collections 1. การเข้าถึง Keys และ Values import collections as col con_code1 = {India: IN, China: CN} con_code2 = {France: FR, United Kingdom: GB} chain = col.ChainMap(con_code1, con_code2) print(chain.

  15. NamedTuple ใน Python: Tuple ที่เข้าถึงได้ทั้ง Index และชื่อ Key

    NamedTuple เป็นคลาสในโมดูล collections คล้าย Dictionary ที่มี Key-Value แต่เข้าถึงได้ทั้ง Index, Attribute Name และ getattr() ลำดับฟิลด์คงที่ 1. การเข้าถึงข้อมูล (Access Methods) import collections as col Employee = col.namedtuple(Employee, [name, city, salary]) e1 = Employee(Asim, Delhi, 25000

  16. Deque ใน Python: คิวสองท้าย (Double-Ended Queue) ประสิทธิภาพสูง

    Deque (Double-Ended Queue) เป็นโครงสร้างข้อมูลผสมระหว่าง Stack และ Queue รองรับการเพิ่ม/ลบที่ทั้งสองข้างได้ใน O(1) อยู่ในโมดูล collections import collections 1. การเพิ่มข้อมูล (Appending) append(x) - เพิ่มขวา appendleft(x) - เพิ่มซ้าย import collections as col my_deque = col.deque(124dfre)

  17. OrderedDict ใน Python: Dictionary ที่จดจำลำดับ Key

    OrderedDict เป็น Subclass ของ dict ความแตกต่างคือ OrderedDict จดจำลำดับการแทรก Key (Insertion Order) ในขณะที่ dict ธรรมดา (Python < 3.7) ไม่รับประกันลำดับ อยู่ในโมดูล collections import collections 1. เปรียบเทียบ Dict vs OrderedDict import collections # Normal dict my_dict = {} my_dict[AA] = 11

  18. สร้าง Website Alarm ด้วย Python: เปิดเว็บอัตโนมัติตามเวลา

    สร้างระบบเตือนเวลา (Alarm) ที่เปิดเว็บไซต์อัตโนมัติเมื่อถึงเวลาที่กำหนด ใช้โมดูลมาตรฐาน: time, webbrowser, sys โจทย์ เมื่อเวลาถึง ให้เปิดเว็บในเบราว์เซอร์ ประโยชน์: เปิดหน้าเว็บประจำวันที่เวลาที่แน่นอน (เช็คข่าว, รายงาน, ระบบภายใน) โดยไม่ต้องนั่งรอ ขั้นตอนการทำงาน รับ URL ที่ต้องการเปิด รับเ

  19. ฟังก์ชัน Decimal ใน Python: คำนวณทศนิยมแม่นยำสูง

    โมดูล decimal ใน Python ใช้สำหรับคำนวณเลขทศนิยมแบบ Floating-point ที่มีความแม่นยำสูง และปัดเศษได้ถูกต้อง (Correctly-rounded) เหมาะสำหรับงานการเงิน วิทยาศาสตร์ ที่ต้องการความแม่นยำ การใช้งาน: import decimal 1. ฟังก์ชัน Square Root (sqrt) และ Exponent (exp) sqrt() - หารากที่สองของ Decimal objec

  20. R vs Python ใน Data Science: เลือกไหนดี?

    ภาพรวม Data Science Data Science เป็นการสำรวจข้อมูลแบบหลายสาขา รวมถึงการพัฒนาอัลกอริทึม การอนุมานจากข้อมูล และเทคโนโลยี เพื่อแก้ปัญหาที่ซับซ้อนอย่างเชิงวิเคราะห์ ข้อมูลคือหัวใจสำคัญ ใน Python ไลบรารี Pandas เป็นเครื่องมือยอดนิยมสำหรับนำเข้าข้อมูลจาก Excel, CSV และแหล่งข้อมูลอื่นๆ ภาพรวมภาษา R R เป็

Total 9001 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:78/451  20-คอมพิวเตอร์/Page Goto:1 72 73 74 75 76 77 78 79 80 81 82 83 84