<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[GRAY Coding - Medium]]></title>
        <description><![CDATA[โค้ดเทาๆ - Medium]]></description>
        <link>https://medium.com/darkcmd?source=rss----8edea64f5c41---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>GRAY Coding - Medium</title>
            <link>https://medium.com/darkcmd?source=rss----8edea64f5c41---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:58:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/darkcmd" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PHP Notes]]></title>
            <link>https://medium.com/darkcmd/php-tutorial-1f091ccd7dd9?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/1f091ccd7dd9</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Fri, 16 Aug 2019 16:55:29 GMT</pubDate>
            <atom:updated>2024-03-28T04:35:30.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*K1ukDw8mcccpovXM.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f091ccd7dd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/php-tutorial-1f091ccd7dd9">PHP Notes</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Variables and Arithmetic Expression]]></title>
            <link>https://medium.com/darkcmd/variables-and-arithmetic-expression-1935a3b6ce7c?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/1935a3b6ce7c</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sun, 17 Dec 2017 19:12:12 GMT</pubDate>
            <atom:updated>2017-12-17T19:12:12.375Z</atom:updated>
            <content:encoded><![CDATA[<p>ตัวแปรและนิพจน์ทางคณิตศาสตร์</p><pre>printcipal = 1000 #Initial amount<br>rate = 0.05       #Interest rate<br>numyears = 5      #number of year<br>year = 1<br>year = 1<br>while year &lt;= numyears:<br>    printcipal - principal * (1 + rate)<br>    print(year,printcipal)<br>    year += 1</pre><p>โปรแกรมข้างบน แสดงถึงการใช้ตัวแปรและนิพจน์ทางคณิตศาสตร์ในการคำนวนค่าคอมมิชชั่นง่ายๆ</p><pre>#Output<br>1 1050.0<br>2 1102.5<br>3 1157.625<br>4 1215.50625<br>5 1276.2815625</pre><p>Python เป็นภาษแบบ Dynamically typed ความหมายก็คือเราสามารถประกาศตัวแปรโดยไม่ต้องบอกชนิดข้อมูลของตัวแปรได้ โดยชนิดของตัวแปรที่ประกาศขึ้นมานั้นจะขึ้นอยู่กับค่าที่เราเก็บใว้ในตัวแปรนั้นๆ ซึ่งก็จะมีชนิดของข้อมูลที่แตกต่างกัน เช่น ถ้าเราประกาศตัวแปร a ขึ้นมา แล้วเอา 10 ไปเก็บใว้ใน a</p><pre>a = 10</pre><p>ซึ่งเลข 10 มันเป็น จำนวนเต็ม(Integer) ก็แสดงว่า ตัวแปร a ก็เป็นชนิดข้อมูลแบบ integer หรือ int นั้นเอง นี้จะเเตกต่างจากภาษา C ที่ว่าเมื่อจะประกาศตัวแปร เราต้องกำหนดชนิดข้อมูลของตัวแปร กำหนดขนาดของข้อมูลและรวมไปถึงกำหนดที่อยู่ในหน่วยความจำที่เอาใว้เก็บค่าข้อมูลด้วย</p><p>จากรูปภาพเเรกที่เเสดงการคำนวณค่าคอมมิชชั่น ที่ตัวแปร principal ถูกกำหนดค่าเริ่มต้นให้เป็นชนิดข้อมูล Integer(int) แต่หลังจากที่โปรแกรมมาถึงบรรทัดที่</p><pre>principal = principal * (1 + rate)</pre><p>ตรง principal * (1 + rate) เนี่ย เขาเรียกว่า Expression หรือนิพจน์ทางคณิตศาสตร์ แม้ว่าค่าเดิมของ principal จะเป็น integer แต่มาถึงตรงชุดคำสั่ง(statement) นี้ค่าใหม่ที่ principal เก็บไว้กลายเป็น ทศนิยม(floating point: float) เพราะว่า rate มันคือ float พอมาคูณกับ integer ผลลัพธ์ทีได้เป็นทศนิยม แล้วเก็บไว้ใน principal ซึ่งคงยังจำกันได้นะครับที่ผมบอกว่า ชนิดของตัวแปรนั้นมันขึ้นอยู่กับชนิดของข้อมูลที่มันกำลังเก็บไว้</p><p>เราจะต้องมีการขึ้นบรรทัดใหม่เมื่อมีการจบชุดคำสั่ง(statement) นั้นๆ แต่ยังไงก็ตามเราสามารถใส่ (;) คั้นใว้ได้ โดยไม่ต้องขึ้นบรรทัดใหม่ เช่น</p><pre>a = 1; b = 2; c = &quot;Hello&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1935a3b6ce7c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/variables-and-arithmetic-expression-1935a3b6ce7c">Variables and Arithmetic Expression</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A tutorial Introduction]]></title>
            <link>https://medium.com/darkcmd/a-tutorial-introduction-a0b931531cb8?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/a0b931531cb8</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sat, 16 Dec 2017 19:05:00 GMT</pubDate>
            <atom:updated>2017-12-17T19:13:15.928Z</atom:updated>
            <content:encoded><![CDATA[<p>บทนำ จะอธิบายถึงหัวข้อต่างๆ แบบไม่เจาะลึก</p><p>ในบทนำนี้ เราจะมาทำความรู้จักกับภาษาไพธอน โดยผมจะพูดคร่าวๆของแต่ละเรื่องและที่สำคัญมากๆ ไม่ได้ลงลึกถึงรายละเอียดของมัน แต่ก็มั่นใจได้ว่ามันครอบคลุม Concept พื้นฐานของ Python แน่นอน อย่างเช่นพวก variables,expressions, control flow, functions, generators, classes, และก็ input/output ในบทความนี้ผมจะใช้ Python3 ในการสอนนะครับ ถ้าใครใช้ Python2 ก็ไม่เป็นไร เพราะ Syntax ที่ใช้จะสนับสนุนทั้งสองเวอร์ชัน แต่ถ้าคำสั่งไหนสนับสนุน ver. ใด ver. หนึ่ง ผมจะอธิบายเพิ่มเติมครับ :) ก่อนจะอ่านเข้าอ่านเนื้อหา ควรจะตืดตั้งไพธอนก่อนนะครับ</p><p>*** Note การติดตั้งไพธอนและ Set path ของ <a href="https://www.youtube.com/watch?v=oBefJifI9R0">Window</a>, <a href="https://www.youtube.com/watch?v=fFShEo17hpQ&amp;index=6&amp;list=PLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW">Linux</a> และ <a href="https://www.youtube.com/watch?v=xhQ-w2bEffs&amp;list=PLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW&amp;index=5">MAC OS</a></p><p><strong>สารบัญ บทนำ</strong></p><ul><li><a href="https://medium.com/darkcmd/introduction-python-84a441227ee5">การทำงานของไพธอน (Running Python)</a></li><li><a href="https://medium.com/darkcmd/variables-and-arithmetic-expression-1935a3b6ce7c">ตัวแปรและนิพจน์ทางคณิตศาสตร์</a></li><li>เงื่อนไข(Condition)</li><li>ไฟล์ Input และ Output</li><li>สตริง(Strings)</li><li>Lists</li><li>Tuples</li><li>Sets</li><li>Dictionaries</li><li>Iteration และ Looping</li><li>Function</li><li>Generators</li><li>Coroutines</li><li>Objects และ Classes</li><li>Exceptions</li><li>Modules</li><li>Getting Help</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0b931531cb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/a-tutorial-introduction-a0b931531cb8">A tutorial Introduction</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part I: The Python Language]]></title>
            <link>https://medium.com/darkcmd/part-i-the-python-language-5046c6b7ac9c?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/5046c6b7ac9c</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sat, 16 Dec 2017 18:16:46 GMT</pubDate>
            <atom:updated>2017-12-16T19:00:13.292Z</atom:updated>
            <content:encoded><![CDATA[<p>บทที่ 1 ภาษาไพธอน(งูหลาม)</p><p><strong>สารบัญ</strong></p><ul><li><a href="https://medium.com/@pugsawayu/a-tutorial-introduction-a0b931531cb8">บทนำ</a></li><li>คำศัพท์(Lexical)และไวยากรณ์(Syntax)</li><li>ประเภท(Types) และวัตถุ(Object)</li><li>Operators และ Expression</li><li>Program Structure และ Control Flow</li><li>Function และ Functional Programming</li><li>Classes และ OOP</li><li>Modules, Package และ Distribution</li><li>Input/Output</li><li>Execution Environment</li><li>Testing, Debugging, Profiling และ Tuning</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5046c6b7ac9c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/part-i-the-python-language-5046c6b7ac9c">Part I: The Python Language</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Python]]></title>
            <link>https://medium.com/darkcmd/introduction-python-84a441227ee5?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/84a441227ee5</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sat, 16 Dec 2017 18:13:28 GMT</pubDate>
            <atom:updated>2017-12-16T19:05:52.524Z</atom:updated>
            <content:encoded><![CDATA[<p>การทำงานของไพธอน</p><p>โปรแกรมที่เขียนด้วยภาษาไพธอนจะ execute โดย interpreter ปกติเเล้ว interpreter จะเริ่มทำงานเมื่อเราพิมพ์คำว่า python ลงบน command shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*WZ2dZNv3i4paQg179vTqbA.jpeg" /></figure><p>จากรูปข้างบน เมื่อ interpreter เริ่มทำงาน หน้าพรอมต์(prompt) จะปรากฏขึ้นมาพร้อมกับเเสดงเวอร์ชั่นของ Interpreter ซึ่งเราจะสามารถพิมพ์คำสั่งลงได้เลย โดยจะเป็นแบบ read-evaluation แปลว่าเมื่อเราพิมพ์คำสั่งใดๆลงไปเเล้ว หลังจากมันทำงานหรือแสดงผลลัพธ์เสร็จ มันก็จะขึ้น prompt ว่างๆรอรับคำสังถัดไป เหมือนเดิมวนไปเรื่อยๆ</p><p>ในปัจจุบันก็มีเครื่องมือที่มีพร้อมทั้ง interpreter และสภาพเเวดล้อมในการพัฒนาโปรแกรมภาษาไพธอน อยู่มากมาย เช่น Jython, IronPyhton, IDLE, ActivePython, Wing IDE, pydev, pycham, และอีกมากมายที่ไม่ได้กล่าวถึง</p><blockquote>ถ้าเราลองพิมพ์คำสั่ง print “Hello World” ลงไปเเล้วเกิด Error นั้นแปลว่า เราน่าจะใช้ Python 3 ซึ่งควรจะเปลี่ยนคำสั่งมาเป็น print(“Hello World”) โดยเพิ่มวงเล็บครอบสตริงใว้</blockquote><p>Python Interactive Mode คือ Feature หนึ่งที่มีประโยชน์มากๆ ซึ่งใน interactive shell นั้น เราสามารถพิมพ์คำสั่งที่ถูกต้องหรือชุดคำสั่งใดๆ และดูผลลัพธ์ได้ทันที ลองมาทดสอบกันดูนะครับ ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*_yXn2RwyoqdueGAegip9jw.png" /></figure><p>เมื่อเราใช้ Python Interactive มันจะมีตัวแปรพิเศษตัวนึง นั้นก็คือ _ ซึ่งเป็นตัวแปรที่จะเก็บผลลัพธ์สุดท้ายที่เราได้และแสดงผลออกมาครั้งล่าสุด มันจะสำคัญเฉพาะตอนที่เราใช้โหมด Interactive มาดูตัวอย่างกันครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Zz5EiFieZ9GmSwzpOoAtMA.png" /></figure><p>ถ้าเราจะสร้างทำโปรแกรมที่คุณต้องรันบ่อยๆ แทนที่เราจะเขียนลงบน Interactive mode ซ้ำๆ เราก็แค่เอาโค้ดไปวางใว้บนไฟล์</p><pre>#hello.py<br>print(&quot;Hello Python&quot;)</pre><p>ไฟล์ที่เก็บคำสั่งไพธอนจะเป็นไฟล์ข้อความธรรมดา(.txt) ดังนั้นเราจะต้องเปลี่ยนนามสุกลไฟล์ให้เป็น .py ก่อน เสร็จเเล้วเมื่อเราจะรันไฟล์ไพธอนของเรา ก็ต้องเปิด command shell ขึ้นมาเเล้วพิมคำว่า python ตามด้วยชื่อไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*DhToD6lwnPam0ne7VexIEg.png" /></figure><p>ถ้าจะทำการ Debugging ผมแนะนำให้ใช้ Tools เพราะว่ามันจะง่ายกว่าและดีกว่า tools ที่แนะนำ pycharm หรือของ python เลย</p><p>ในกรณีที่เราจะออกจาก Interactive shell สามารถใช้คำสั่ง &gt;&gt; raise SystemExit หรือกด Ctrl+Z</p><p>แนะนำวิดีโอสอน</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW&amp;url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDI7eca5Kzdc%2Fhqdefault.jpg%3Fsqp%3D-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ%3D%3D%26rs%3DAOn4CLAU-mrFDE5K3YVTThxHgRGS00n1oQ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="853" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0822c69ca2aaa355949b2f7fbf7b46a2/href">https://medium.com/media/0822c69ca2aaa355949b2f7fbf7b46a2/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPL0ROnaCzUGB4ieaQndKybT9xyoq2n9NGq&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU2l1xgpVsuo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FU2l1xgpVsuo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/29590ca6e41bd6ef4f1ef980751d4954/href">https://medium.com/media/29590ca6e41bd6ef4f1ef980751d4954/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84a441227ee5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/introduction-python-84a441227ee5">Running Python</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Programming]]></title>
            <link>https://medium.com/darkcmd/python-programing-e39b544fa4f9?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/e39b544fa4f9</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sat, 16 Dec 2017 09:15:05 GMT</pubDate>
            <atom:updated>2017-12-16T18:17:51.041Z</atom:updated>
            <content:encoded><![CDATA[<p>การเขียนโปรแกรมภาษาไพธอน</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*WGrIIncstcUFxnzd.jpg" /></figure><p><strong>สารบัญ</strong></p><p>Part I: <a href="https://medium.com/darkcmd/part-i-the-python-language-5046c6b7ac9c">The Python Language</a></p><p>Part II: The Python Library</p><p>Part III: Extending and Embedding</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e39b544fa4f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/python-programing-e39b544fa4f9">Python Programming</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Python] String Processing 1]]></title>
            <link>https://medium.com/darkcmd/python-string-processing-f2191d801c16?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/f2191d801c16</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 19:48:27 GMT</pubDate>
            <atom:updated>2017-12-16T09:17:24.843Z</atom:updated>
            <content:encoded><![CDATA[<p>การประมวลผลสตริง ตอนที่ 1</p><p>สตริง(String) คือ ตัวอักขระ(Character) หลายๆตัวมาเรียงต่อกัน ตัวอย่างเช่น</p><pre>str = &quot;Hello World&quot;</pre><p>จริงๆ มันก็เหมือน Array ของอักขระเรียงต่อกันนั้นแหระ ทีเนี่ย เราจะเกิดคำถามว่าเพราะอะไรถึงรู้ว่าเป็นอาเรย์ใช่ไหม ? ถ้าเราลองเขียน Code ดังนี้</p><pre>print(str[0])</pre><p>สิ่งที่มันจะเเสดงออกมาคือ “H” งั้นก็แสดงว่า str[1] ต้องเป็น “e” แน่นอน จึงทำให้เรารู้ว่าเราสามารถเข้าถึง Character ใน String ได้ โดยอ้างอิงจาก index</p><p>ในกรณีที่เราจะแปลงชนิดข้อมูลอื่นๆ มาเป็นสตริงนะครับ เราสามารถใช้ keyword คำว่า str(…) ได้ครับ โดยในวงเล็บจะเป็นสิ่งที่เราต้องการแปลงนั้นเอง ลองดูตัวอย่างนะครับ</p><pre>a = 123</pre><pre>#คำสั่ง type() ใช้เช็ค Data type ของข้อมูลครับ</pre><pre>print(type(a)) # int</pre><pre>print(str(a)) # =&gt; &quot;123&quot;<br>print(type(str(a))) # =&gt; str</pre><p>ระวังนะครับ เราไม่สามารถเอาสตริงไปบวกกับจำนวนเต็มได้ แต่สามารถบวกกับสตริงเหมือนกันได้ โดยการบวกนี้จะเป็นการต่อสตริง เช่น</p><pre>firstname = &quot;Sittikorn&quot;<br>lastname = &quot;Prasanlak&quot;<br>myname1 = firstname + &quot; &quot; + lastname ### &quot;Sittikorn Prasanlak&quot;<br># หรือจะเอาสตริงมาบวกโดยตรงก็ได้<br>myname2 = &quot;Sittikorn &quot; + &quot;Prasanlak&quot; ### &quot;Sittikorn Prasanlak&quot;</pre><p>อีกกรณี เราสามารถเอาสตริงไปคูณกับจำนวนเต็มได้(integer : int) เช่น</p><pre>str = &quot;a&quot;<br>print(a*6) # -&gt; &quot;aaaaaa&quot; </pre><p>มาดูอีกปัญหานึงนะครับ เราจะลองมาเขียนโปรแกรมบวกเลขดูนะครับ โดยใช้คำสั่ง input(…) เป็นคำสั่งที่ใช้รับข้อมูลจากแป้นพิมพ์</p><pre>a = input(&quot;Enter your number1: ) # สมมุติ ใส่ 1<br>b = input(&quot;Enter your number2: ) # สมมุติ ใส่ 1</pre><pre>print(Result is ,a+b) # -&gt; ผลลัพธ์ Result is 11</pre><p>เราจะเห็นสิ่งที่ผิดพลาดเเล้วใช่ไหมละครับ ทำไม? a+b ถึงได้ 11 มันควรจะได้สองซิก็เพราะว่า ค่าที่เรารับเข้ามาจากแป้นพิมพ์ จะเป็นชนิดข้อมูลสตริงครับ ที่ผมเคยอธิบายคือเราสามารถเอาสตริงบวกกันได้ โดยผลลัพธ์จะเป็นการนำสตริงมาต่อกัน เลยทำให้ a = “1” และ b = “1” บวกกันได้ “11” นั้นเอง</p><p>ทีเนี้เราจะทำยังไงให้มันบวกได้ คำตอบคือ เราก็แปลงให้มันเป็นตัวเลข(int) ก่อนดิ</p><pre>a = int(input(<strong>&quot;Enter your number1: &quot;)</strong>) # สมมุติ ใส่ 1<br>b = int(input(<strong>&quot;Enter your number2: &quot;</strong>)) # สมมุติ ใส่ 1<br>print(<strong>&quot;Result is&quot;</strong>, a+b) <em># -&gt; Result is 2 </em></pre><h4>บริการพื้นฐานของสตริง (ยกมาบางตัวที่น่าสนใจนะครับ)</h4><ul><li>len ใช้ในการนับจำนวนตัวอักขระในข้อความสตริง</li></ul><pre>str = &quot;He is programmer&quot;<br>print(len(str)) #output is 16</pre><ul><li>lower ใช้ในการแปลงตัวอักขระตัวพิมพ์ใหญ่ให้เป็นตัวพิมพ์เล็ก</li></ul><pre>name = &quot;My name&#39;s DarkCMD&quot;<br>print(name.lower()) # ==&gt; my name&#39;s darkcmd</pre><ul><li>upper ใช้ในการแปลงตัวอักขระตัวพิมพ์เล็กให้เป็นตัวพิมพ์ใหญ่</li></ul><pre>print(name.upper()) # ==&gt; MY NAME&#39;S DARKCMD</pre><ul><li>strip ใช้ในการตัดช่องว่างด้านซ้ายเเละขวาของสตริงออก</li></ul><pre>str = &quot; Hello Mom &quot;<br>print(str.strip()) # -&gt; &quot;Hello Mom&quot;</pre><ul><li>find ใช้หาคำหรือตัวอักษรภายในสตริงข้อความ ถ้าเจอจะคืนตำแหน่งที่พบกลับมา แต่ถ้าไม่เจอจะคืน -1</li></ul><pre>str = &quot;Hello&quot;<br>print(str.find(&quot;la&quot;)) # -&gt; -1 <br>print(str.find(&quot;lo&quot;)) # -&gt;  3</pre><ul><li>[] ใช้ในการเข้าถึงตัวอักขระในสตริง ผมเคยพูดมาเเล้วว่า str[0] ก็จะเอา character เเรกมา ความแปลกของ python คือ มันสามารถใส่ index ติดลบได้ เช่น str[-1] มันจะเข้าถึง character ตัวสุดท้ายของสตริง ยังไม่พอ เรายังบอกช่วงที่เราจะเข้าถึงได้ มาลองดูโค้ดกัน</li></ul><pre>info = &quot;Sittikorn Prasanlak Computer Engineering Security Movie&quot;<br>myname = info[0:19]<br>print(myname) # -&gt; &quot;Sittikorn Prasanlak&quot;</pre><ul><li>in ใช้ในการค้นหาคำหรือตัวอักขระภายในตัวแปร เพื่อความเข้า เราต้องดูโค้ด</li></ul><pre>Grade = &quot;AAAFDBCC&quot;<br>if &quot;F&quot; in Grade:<br> print(&quot;ไม่มีสิทธิ์ได้เกียรตินิยม&quot;)</pre><h4>Method Chaining</h4><p>ในหลายๆครั้งที่เราใช้งานตัวเเปรสตริง เราจำเป็นต้องใช้บริการของมันหลายๆบริการพร้อมกัน ใน Python เราสามารถเรียกใช้บริการสตริงได้พร้อมกัน โดยเรียกต่อๆกันหลัง (.) ได้เลย สิ่งนี่เขาเรียกว่า Method Chaining</p><pre>name = &quot; Sittikorn Prasanlak       &quot;<br>print(name.strip().upper()) # -&gt; &quot;SITTIKORN PRASANLAK&quot;</pre><p>นี่ก็เป็นเนื้อหาพื้นฐานของการใช้ String ใน Python นะครับ ครั้งหน้าผมจะมาพูดถึงเนื้อหา String ต่อ แต่เป็นเรื่องของการ Read/Write ไฟล์และเรื่องที่เกียวข้องนิดหน่อย นะครับ</p><p>ปล. ท่านใดที่เข้ามาอ่านอาจจะไม่เข้าใจ เพราะความเข้าใจของแต่ละคนไม่เหมือนกัน ก็ขออภัยด้วยนะครับ</p><p>ปล2. ถ้าเพื่อนๆท่านใดพบข้อผิดพลาดหรือผมอาจจะเข้าใจผิดบางอย่าง ช่วยเเจ้งในคอมเม้นหน่อยนะครับ ช่วยๆกัน 5555+</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2191d801c16" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/python-string-processing-f2191d801c16">[Python] String Processing 1</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[พื้นฐานแนวคิดเรื่องความปลอดภัย]]></title>
            <link>https://medium.com/darkcmd/%E0%B8%9E%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B8%90%E0%B8%B2%E0%B8%99%E0%B9%81%E0%B8%99%E0%B8%A7%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B9%80%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%9B%E0%B8%A5%E0%B8%AD%E0%B8%94%E0%B8%A0%E0%B8%B1%E0%B8%A2-21473fe0692b?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/21473fe0692b</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 19:48:07 GMT</pubDate>
            <atom:updated>2017-12-14T17:58:40.187Z</atom:updated>
            <content:encoded><![CDATA[<p>(Fundamental Security Concept)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*SnPSoqjzn4lY18Bk.jpg" /></figure><p>~ ก่อนจะเริ่มเข้าเรื่องผมขอถามคำถามก่อนนะครับว่าถ้าเรามีเงินสดอยู่ในห้อง เราจะปกป้องรักษาเงินนั้นยังไง ???? ซึ่งแน่นอนว่าเราจะต้องมีคำตอบเป็นวิธีการที่เราคิดได้เยอะเเยะมากมายใช่ไหมละครับ เเล้วถ้าผมจะถามต่ออีกละว่าทำไมเราต้องรักษาเงินนั้นด้วยละครับ อ๊ะ อ๊าาาา ทำไมหน๊ะ ทำไม ?</p><p>~ งั้นลองเปลี่ยนจากเงินเป็นสิ่งของอะไรก็ได้ที่เราต้องการปกป้องมัน ทำไมเราถึงต้องปกป้องสิ่งของนั้น</p><ul><li>มันมีค่า ?</li><li>หายาก ?</li><li>แสดงความเป็นเจ้าของ ?</li><li>เราจำเป็นต้องใช้ ?</li><li>มันมีจำกัด ?</li><li>เป็นความลับ ?</li><li>บางสิ่งเราจำเป็นต้องปกป้องมันเพราะเราเกลียดมัน ?</li><li>อื่นๆ มากมาย</li></ul><p>จากเริ่มแรกที่ผมพูดถึงเราจะปกป้องรักษาเงินยังไงใช่ไหมครับ ก่อนจะปกป้องเงินของเราได้นั้นเราจะต้องมีความกังวลว่ามันจะหาย กลัวโจรขโมย มันมีค่า จำเป็นต้องใช้ เป็นต้น สิ่งๆต่างๆเรานี้เเหระ ที่เรียกว่า Concern จากความกังวลนี้ก็ส่งผลให้สัญชาตญาณเราหาวิธีปกป้องมัน ไม่ว่าจะเป็น เอาไปฝากธนาคาร เอาไปซ่อนใตู้เซฟ เอาไปฝัง(สมัยโบราณ อิอิ) เป็นต้น ทุกอย่างล้วนเป็นวิธีการปกป้องเงินของเราเอง ที่กล่าวมาทั้งหมดนี้มันคือพื้นฐานแนวคิดสำคัญของเรื่องความปลอดภัยเลยครับ</p><p><strong>Protection Idea</strong></p><p>จากที่กล่าวมาข้างต้นว่าหลังจากเกิด Concern เเล้ว จะส่งผลให้ทำการ Protect สิ่งของๆเราซึ่งมันจะทำให้เข้าใจได้ชัดในสิ่งที่ผมจะกลาวต่อไป โดยผมจะพูดถึงแนวคิดการปกป้องข้อมูลมีดังต่อไปนี้</p><ul><li><strong>Frustration</strong> คือการทำให้มันเข้ายากหรือกาารเข้ารหัส(Encryption)นั้นเอง แนวคิดนี้ไม่ใช่ว่าจะเข้าไม่ได้นะ แต่ทำให้มันเข้ายากขี้น</li><li><strong>Deception </strong>คือการซ่อนหรือการทำให้หาไม่เจอ อาจจะใช้วิธีหลอกล่ออะไรก็ได้ เช่น Salting เป็นการสร้างสิ่งเหมือนๆกันหลายๆอันเพื่อซ่อนของจริงใว้ เป็นต้น</li><li><strong>Resistance </strong>จะคล้ายๆ Frustration แต่อันนี้จะเข้าไม่ได้ เช่น ถ้าโปรเซสไหนรันเเล้วเกิดปัญหา ก็จะไม่ให้โปรเซสนั้นรันเลย</li><li><strong>Detection</strong> คือการป้องกัน สร้างขอบเขต ข้อกำหนด หรือตรวจสอบความเป็นเจ้าของใว้</li><li><strong>Recovery </strong>คือวิธีการกูคืนระบบ ถ้ามองเป็นแบบในชีวิตก็คือ ถ้าของในบ้านหายเราจะทำยังไง บางคนอาจจะเเจ้งตำรวจ บางคนติดกล้องใว้ก็อาจจะเช็คกล้องวงจรปิด อะไรประมาณนี้</li></ul><p>~ เดียวครั้งหน้าผมจะเอาการโจมตีแบบ Buffer Overflow มาจำแนกให้ดูว่า Protection Idea แตละอันนั้นใช้แก้ปัญหายังไงผมจะเขียนใว้คร่าวๆก่อนจบนะครับ</p><ul><li><strong>Deception : </strong>ทำการสุ่มหน่วยความจำ เพราะการเกิด Buffer Overflow มันจะทำการโจมตีที่ Address เดิมๆ ถ้าการโจมตีนั้นสำเร็จ</li><li><strong>Frustration : </strong>คือการเอาข้อมูลไปใว้ใน Sandbox</li><li><strong>Resistance :</strong> อันนี้คือถ้ามีการโจมตี มันจะไม่ให้รันอีกต่อไป</li><li><strong>Detection : </strong>การเช็คว่าหน่วยความจำที่ใช้ เป็นแอดเดรสเดิมหรือป่าว</li><li><strong>Recovery : </strong>เช็คใน Task Manager เเล้วหยุดโปรเซสนั้นๆ</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21473fe0692b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/%E0%B8%9E%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B8%90%E0%B8%B2%E0%B8%99%E0%B9%81%E0%B8%99%E0%B8%A7%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B9%80%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%9B%E0%B8%A5%E0%B8%AD%E0%B8%94%E0%B8%A0%E0%B8%B1%E0%B8%A2-21473fe0692b">พื้นฐานแนวคิดเรื่องความปลอดภัย</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เครื่องมือใน Kali Linux]]></title>
            <link>https://medium.com/darkcmd/%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87%E0%B8%A1%E0%B8%B7%E0%B8%AD%E0%B9%83%E0%B8%99-kali-linux-1f52cc1986d4?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/1f52cc1986d4</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 19:47:35 GMT</pubDate>
            <atom:updated>2017-09-14T17:06:34.788Z</atom:updated>
            <content:encoded><![CDATA[<p>ใน Kali Linux มีเครื่องมือเยอะมากในการทดสอบเจาะระบบ จะแบ่งเป็นหมวดๆตามนี้นะครับ</p><ul><li><strong>Information gathering</strong>: หมวดนี้จะประกอบไปด้วยเครื่องมือที่ใช้เกี่ยวกับการรวบรวมข้อมูลพวก DNS, IDS/IPS, network scanning, operating systems, routing, SSL, SMB, VPN, voice over IP, SNMP, เเละ e-mail addresses</li><li><strong>Vulnerability assessment</strong>: ในหมวดนี้ก็จะเป็นพวก tools ที่ใช้ในการสแกนช่องโหว่ทั่วๆไป และก็ยังมี tools ที่ใช้ประเมิน Cissco Network อีกด้วย</li><li><strong>Web applications</strong>: หมวดนี้จะเป็น tools ที่เกี่ยวกับการสแกนเว็บแอพลิเคชั่น เช่น database exploitation, web application fuzzers, web application proxies, web crawlers, และ web vulnerability scanners</li><li><strong>Password attacks</strong>: tools ในการโจมตีรหัสผ่านนั้นจะอยู่ในหมวดนี้</li><li><strong>Exploitation tools</strong>: ในหมวดนี้จะประกอบไปด้วย tools ที่ใชค้นหาช่องโหว่ที่เกิดจาก Bug ของซอฟเเวร์ และยังมี tools ที่ใช้โจมตีทางวิศวกรรม (Social Engineer) ด้วย</li><li><strong>Sniffing and spoofing</strong>: จะประกอบไปด้วย tools ที่ใช้ในการดักจับข้อมูลและตรวจสอบ traffic ของเว็บ รวมไปถึงเครื่องมือ ปลอมแปลงเครือข่ายอีกนะ เช่นพวก Ettercap และ Yersinia</li><li><strong>Maintaining access</strong>: เครื่องมือในหมวดหมู่นี้อ่ะนะ จะเป็นเครื่องมือที่จะทำให้เราเข้าถึงเครื่องเป้าหมายได้ โดยการที่จะเข้าไปได้นั้นพวก Hacker จะต้องมีสิทธิพิเศษใช่ไหมละ พอเข้าได้เสร็จมันก็ต้องสร้าง Backdoor เพื่อครั้งหน้าจะได้กลับเข้ามาใหม่ แน่นแนเครื่องมือพวกนี้จะอยู่หมวดหมู่นี้</li><li><strong>Reporting tools</strong>: จะประกอบไปด้วย tools ที่ช่วยให้สามารถบันทึกกระบวนการทดสอบและผลการทดสอบ</li><li><strong>System services</strong>: ตามชื่อเลยครับ ให้บริการระบบต่างๆนาๆ ที่เป็นประโยช์ต่อการทดสอบสอบเจาะระบบ เช่น พวก Apache service, MySQL service, SSH service, และ Metasploit service</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f52cc1986d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87%E0%B8%A1%E0%B8%B7%E0%B8%AD%E0%B9%83%E0%B8%99-kali-linux-1f52cc1986d4">เครื่องมือใน Kali Linux</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TOP 10 Security tools]]></title>
            <link>https://medium.com/darkcmd/top-10-security-tools-b3157da0306a?source=rss----8edea64f5c41---4</link>
            <guid isPermaLink="false">https://medium.com/p/b3157da0306a</guid>
            <dc:creator><![CDATA[ขนมปัง สังขยา]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 19:46:55 GMT</pubDate>
            <atom:updated>2017-09-14T17:06:16.409Z</atom:updated>
            <content:encoded><![CDATA[<p>10 อันดับ เครื่องมือที่นักทดสอบเจาะระบบใช้กันเยอะสุด</p><ol><li>aircrack-ng</li></ol><p>2. burp-suite</p><p>3. hydra</p><p>4. john</p><p>5. maltego</p><p>6. metasploit</p><p>7. nmap</p><p>8. sqlmap</p><p>9. wireshark</p><p>10. zaproxy</p><p>*ส่วนรายละเอีดอันไหนทำอะไร จะกล่าวต่อไปนะคร้าบบบ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3157da0306a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/darkcmd/top-10-security-tools-b3157da0306a">TOP 10 Security tools</a> was originally published in <a href="https://medium.com/darkcmd">GRAY Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>