ค้นหาบล็อกนี้

วันเสาร์ที่ 30 พฤศจิกายน พ.ศ. 2556

การบ้านครั้งที่ 4 การอ่านข้อมูลจากไฟล์ Text แล้วนำมาแปลงเป็นไฟล์ csv

หลักการในการทำ

          ในการสร้างโปรแกรมนี้เราจะทำการอ่านข้อมูลในไฟล์ข้อความ (text) มาทีละบรรทัด  ซึ่งข้อมูลที่เราเก็บไว้ในไฟล์ข้อความในแต่ละบรรทัดจะเป็นข้อมูลของแต่ละคน  ซึ่งการเก็บข้อมูลในแต่ละประเภทจะใช้เครื่องหมาย  \  ในการแบ่งข้อมูลแต่ละประเภท มีรูปแบบในการเก็บข้อมูลดังนี้

student ID \First name \Last name \Nickname \Birthday \Age \Sex \Religion \Weight \High \Email \Address \Facebook \Tell.

ตัวอย่างการเก็บข้อมูล เช่น
5501012630133 \Tatchagon \Koonkoei \Kol \02.06.1993 \20 \male \Buddhism \50 \168 \o_k_t@hotmail.com \111/1 M.3 Banmai Thamuang Kanchanaburi \facebook.com/tatchagon \0826810461

เราจะให้โปรแกรมอ่านข้อมูลเหล่านี้มาทีละบรรทัดแล้วนำข้อมูลเหล่านี้ซึ่งแบ่งข้อมูลแต่ละประเภทด้วยเครื่องหมาย \ (backslash) มาเปลี่ยนเป็นเครื่องหมาย ,(comma) แทน  แล้วบันทึกไฟล์ใหม่นี้เป็นไฟล์ที่มีนามสกุลแบบ csv เราก็จะได้โปรแกรมแบบ csv ซึ่งสามารถเปิดได้ด้วยโปรแกรมประเภท spreadsheet เช่น MS Excel

โค้ดของโปรแกรมนี้แสดงดังด้านล่าง

ศึกษาเพิ่มเติมไฟล์ประเภท csv

วันอาทิตย์ที่ 24 พฤศจิกายน พ.ศ. 2556

การบ้านครั้งที่ 3 การอ่านข้อมูลจากไฟล์ Text แล้วนำมาแสดงผลผ่านหน้าเพจ Html

หลักการในการทำ

          ในการสร้างโปรแกรมนี้เราจะทำการอ่านข้อมูลในไฟล์ข้อความ (text) มาทีละบรรทัด  ซึ่งข้อมูลที่เราเก็บไว้ในไฟล์ข้อความในแต่ละบรรทัดจะเป็นข้อมูลของแต่ละคน  ซึ่งการเก็บข้อมูลในแต่ละประเภทจะใช้เครื่องหมาย  \  ในการแบ่งข้อมูลแต่ละประเภท มีรูปแบบในการเก็บข้อมูลดังนี้

student ID \First name \Last name \Nickname \Birthday \Age \Sex \Religion \Weight \High \Email \Address \Facebook \Tell.

ตัวอย่างการเก็บข้อมูล เช่น
5501012630133 \Tatchagon \Koonkoei \Kol \02.06.1993 \20 \male \Buddhism \50 \168 \o_k_t@hotmail.com \111/1 M.3 Banmai Thamuang Kanchanaburi \facebook.com/tatchagon \0826810461

เราจะให้โปรแกรมอ่านข้อมูลเหล่านี้มาทีละบรรทัดแล้วนำข้อมูลเหล่านี้มาแยกเป็นประเภท  แล้วนำไปสร้างเป็นไฟล์ html ของแต่ละคน  เมื่อสร้าง html ของแต่ละคนเสร็จแล้ว  ก็สร้างไฟล์ index.html เพื่อเป็นหน้าเพจที่รวม Link ของ html แต่ละคน

โค้ดด้านล่างเป็นการเรียกอ่านข้อมูลในไฟล์ Text มาทีละบรรทัดแล้วนำมาเก็บไว้ใน List


และโค้ดด้านล่างนี้เป็นการนำข้อมูลจาก List ที่เราอ่านแล้ว มาทำเป็นไฟล์ Html เพื่อแสดงข้อมูลในหน้าเว็บเพจ


หมายเหตุ: มีส่วนที่เป็นโค้ด Html บางส่วนที่ถูกรันใน Blog นี้ดังนั้นโค้ดที่แสดงนี้อาจมีบางส่วนที่ไม่สามารถแสดงออกมาให้เห็นได้

นี่คือโค้ดทั้งหมดของโปรแกรมนี้

import webbrowser,os
def importData(nameFile):
    #open data text file and store data in list
    file_data=open(nameFile)
    list_profile=[]#create new list for store profile data
    for i in file_data.xreadlines():#read data each line
        list_profile.append(i)#put data in list
    list_profile.sort()#sorted data
   
    #create new directory for store html file
    newDir='data_html'
    if not os.path.isdir(newDir):#Check that there is no directory.
        os.makedirs(newDir)#create new directory
    return list_profile

def make_html(list_profile):
    list_allHtml=[]#list store all profile
    list_nameLink=[]#list store name of all file html is create
    list_data=[]#list store data for put in body of html
    for i in list_profile:
        list_temp=i.split(" \\")#split data by \
        #create string data for html
        str_temp='<font size=\"4\" color=#0000FF>Student ID:</font><dd><font size=\"5\" color=#005500>'+list_temp[0]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>First Name:</font><dd><font size=\"5\" color=#005500>'+list_temp[1]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Last Name:</font><dd><font size=\"5\" color=#005500>'+list_temp[2]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Nickname:</font><dd><font size=\"5\" color=#005500>'+list_temp[3]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Birthday:</font><dd><font size=\"5\" color=#005500>'+list_temp[4]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Age:</font><dd><font size=\"5\" color=#005500>'+list_temp[5]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Sex:</font><dd><font size=\"5\" color=#005500>'+list_temp[6]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Religion:</font><dd><font size=\"5\" color=#005500>'+list_temp[7]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Weight:</font><dd><font size=\"5\" color=#005500>'+list_temp[8]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>High:</font><dd><font size=\"5\" color=#005500>'+list_temp[9]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Email:</font><dd><font size=\"5\" color=#005500>'+list_temp[10]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Address:</font><dd><font size=\"5\" color=#005500>'+list_temp[11]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Facebook:</font><dd><font size=\"5\" color=#005500>'+list_temp[12]+'</font><br>'
        str_temp+='<font size=\"4\" color=#0000FF>Tell:</font><dd><font size=\"5\" color=#005500>'+list_temp[13]+'</font><br><br>'
       
        list_allHtml.append(''+list_temp[0]+' '+list_temp[1]+' '+list_temp[2])
        list_nameLink.append(list_temp[0])
        list_data.append(str_temp)
   
    str_temp=''
    for i in range(len(list_nameLink)):
        str_link=''
        if i!=0:
            str_link+='<font size=\"4\"><a href='+list_nameLink[i-1]+'.html'+'>Back</a></font>&nbsp&nbsp&nbsp&nbsp&nbsp'
        str_link+='<font size=\"4\"><a href=index.html>Home</a></font>&nbsp&nbsp&nbsp&nbsp&nbsp'
        if i+1!=len(list_nameLink):
            str_link+='<font size=\"4\"><a href='+list_nameLink[i+1]+'.html'+'>Next</a></font>'
       
        html="""
            <html>
            <head><title>"""+list_allHtml[i]+"""</title></head>
            <body>"""+list_data[i]+str_link+"""</body>
            </html>
        """
       
        path='./data_html/'+list_nameLink[i]+'.html'
        f=open(path,'w')
        f.write(html)
        f.close()
        str_temp+='<a href='+list_nameLink[i]+'.html target=_blank><font size=\"5\">'+list_allHtml[i]+'</font></a><br>'
   
    f=open('./data_html/index.html','w')
    html="""
        <html>
        <head><title>Home</title></head>
        <body>"""+str_temp+"""</body>
        </html>
    """
    f.write(html)
    f.close()


make_html(importData('data.txt'))
webbrowser.open_new('./data_html/index.html')
print 'DONE...'


การบ้านครั้งที่ 2 การแสดง Directory ใน Html และการสร้างปฏิทิน จากภาษา Python

1.โปรแกรมแสดง Directory ในรูปแบบ html
2.โปรแกรมแสดงปฏิทิน วันและเดือนปัจจุบัน
3.โปรแกรมแสดงปฏิทิน ปีปัจจุบัน

วันเสาร์ที่ 16 พฤศจิกายน พ.ศ. 2556

การ install django

1.โหลดโปรแกรม Django

Link Download Django
หลังจากโหลดเสร็จแล้วให้ทำการแตกไฟล์ที่โหลดมา

2.เมื่อโหลดเสร็จแล้วถ้าใช้ Windows ก็ให้ทำการเปิด cmd ขึ้นมา  หรือถ้าใช้ Linux ก็เปิด Terminal


หน้าต่าง cmd



3.ในหน้าต่าง cmd ให้ทำการพิมพ์(เครื่องหมาย _ ในที่นี้แทนช่องว่าง) 
cd_ที่อยู่ที่ทำการแตกไฟล์ Django  
พิมพ์เสร็จแล้วกด Enter
เช่น  cd C:\Downloads\Django-1.6  ในที่นี้ใช้ Django Version 1.6

4.เมื่อเข้าไปในที่อยู่ที่ทำการแตกไฟล์ได้แ้ล้ว  ให้พิมพ์ในหน้าต่าง cmd (เครื่องหมาย _ ในที่นี้แทนช่องว่าง)  
ถ้าใช้ windows ให้พิมพ์ python_setup.py_install
ถ้าใช้ Linux ให้พิมพ์ sudo_python_setup.py_install
พิมพ์เสร็จแล้วให้กด Enter  หลังจากนั้นต้องรอสักครู่ให้โปรแกรมทำการติดตั้ง

5.เมื่อติดตั้งเสร็จแล้วให้ลองทำการสร้างไฟล์ภาษา python แล้วลอง  import django  ดูถ้า run ได้ก็หมายความว่าได้ทำการติดตั้งสำเร็จแล้ว

ถ้าไม่เข้าใจวิธีการติดตั้งสามารถดู VDO ด้านล่างเพื่อให้เข้าใจมากยิ่งขึ้น


วันพุธที่ 13 พฤศจิกายน พ.ศ. 2556

การบ้านครั้งที่ 1 เรียนรู้การ print ข้อความใน Python และการสร้างไฟล์ Html จาก Python

1. เรียนรู้การ print ข้อความในภาษา Python 2.x
          รูปแบบการ print ข้อความในภาษา Python 2.x
print "ข้อความที่ต้องการ"  หรือ  print 'ข้อความที่ต้องการ'
ข้อความที่ต้องการแสดงนั้นอาจจะเป็นข้อมูลชนิด String ,int ,float ,list ฯลฯ

          โค้ดด้านล่างเป็นโค้ดในภาษา Python 2.7  ซึ่งใช้คำสั่ง print เพื่อเป็นการแสดงข้อมูลออกมาผ่านทาง command line ในที่นี้คือข้อมูลส่วนตัว

print "My name is       : Tatchagon  Koonkoei"
print "My student ID is : 5501012630133"
print "Birthday         : June 2, 1993"
print "Gender           : Male"
print "Hometown         : Thamuang Kanchanaburi Thailand"
print "Religious Views  : Buddhism"
print "Email            : o_k_t@hotmail.com"
print "Facebook         : http://facebook.com/tatchagon"
print "Education        :"
print "     Primary Education   : Taladsumrong School"
print "     Secondary Education : Srinagarindra The Princess Mother School Kanchanaburi"
print "     University Education: King Mongkut's University of Technology North Bangkok"


2. เรียนรู้การสร้างไฟล์ Html จากภาษา Python 2.x
          เราสามารถใช้ภาษา Python2.x ในการสร้างไฟล์แบบ Html ได้  นอกจากนี้แล้วเรายังสามารถสร้างไฟล์ำได้อีกหลายประเภทเช่น ไฟล์ข้อความ(*.txt)  ไฟล์ CSV(*.csv) เป็นต้น

          ในการสร้างไฟล์ Html จากภาษา Python2.x นั้นมีรูปแบบการเขียนโค้ดดังนี้

รูปแบบการสร้างไฟล์ Html จากภาษา Python2.x

ชื่อตัวแปร = open( 'ชื่อไฟล์.html' ,'โหมด' )
หมายเหตุ: ชื่อตัวแปรกับชื่อไฟล์เราสามารถตั้งได้ตามต้องการ  ส่วนโหมดนั้นจะมีดังนี้
                 r        คือ โหมด reading
                 w      คือ โหมด writing
                 r+     คือ โหมด opens for reading and writing (cannot truncate a file)
                 w+    คือ โหมด writing and reading (can truncate a file)
                 rb+   คือ โหมด reading or writing a binary file
                 wb+  คือ โหมด writing a binary file
                 a+     คือ โหมด opens for appending
ชื่อตัวแปร.write( 'ข้อความที่ต้องการเขียน' )
หมายเหตุ: ข้อความที่ต้องการเขียนนี้ในที่นี้เราจะสร้างไฟล์ Html ข้อความที่เขียนจึงเป็นรูปแบบของ  
 ภาษา้ Html  และข้อความที่เราจะทำการเขียนลงไปในไฟล์นี้เราสามารถที่จะใช้คำสั่งนี้เขียนทีละบรรทัดเช่น
ชื่อตัวแปร.write( 'ข้อความ 1' )
ชื่อตัวแปร.write( 'ข้อความ 2' )
.
.
.
ชื่อตัวแปร.write( 'ข้อความ n' )
หรือเราจะใช้การสร้างข้อความแบบหลายบรรทัดแล้วค่อยมาเขียนลงในไฟล์ทีเดียวก็ได้  การสร้างข้อความแบบหลายทัดมีวิธีการคือเราจะใช้เครื่องหมาย " (Double quotes) 3 อัน  เปิดก่อนข้อความและปิดหลังข้อความเช่น
"""
ข้อความบรรทัดที่ 1
ข้อความบรรทัดที่ 2
.
.
.
ข้อความบรรทัดที่ n
"""
เมื่อได้ข้อความหลายบรรทัดแล้วเราก็สามารถนำไปเขียนลงในไฟล์ Html ได้
เมื่อทำการเขียนข้อความทั้งหมดลงในไฟล์เสร็จแล้วเราก็จะทำการปิดไฟล์ที่เขียนโดยใช้คำสั่ง
ชื่อตัวแปร.close()

ตัวอย่างโค้ดการเขียนไฟล์ Html โดยภาษา Python2.x

f=open('work1_2.html','w')

f.write('<html>\n')
f.write('<head>\n')
f.write('<title>Tatchagon Koonkoei')
f.write('</title>\n')
f.write('</head>\n')
f.write('<body bgcolor="#76EE00">\n')
f.write('<center><font size="6" color="#00008B">Profile</font></center><br><br><br>\n')
f.write('<font size="4" color="#00008B">My name is :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Tatchagon Koonkoei</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">My student ID is :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>5501012630133</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Birthday :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>June 2, 1993</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Gender :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Male</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Hometown :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Thamuang Kanchanaburi Thailand</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Religious Views :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Buddhism</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Email :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>o_k_t@hotmail.com</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Facebook :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>http://facebook.com/tatchagon</b></font><br><br>\n')
f.write('<font size="4" color="#00008B">Education :</font><br>\n')
f.write('<font size="4" color="#00008B"><dd>    Primary Education :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Taladsumrong School</b></font><br>\n')
f.write('<font size="4" color="#00008B"><dd>    Secondary Education :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>Srinagarindra The Princess Mother School Kanchanaburi</b></font><br>\n')
f.write('<font size="4" color="#00008B"><dd>    University Education :</font>\n')
f.write('<font size="4" color="#F5FFFA"><b>King Mongkut\'s University of Technology North Bangkok</b></font><br>\n')
f.write('</body>\n')
f.write('</html>\n')

f.close()

          เมื่อทำการ Run โค้ดตัวอย่างเราจะได้ไฟล์ที่มีชื่อว่า work1_2.html ในไฟล์นี้จะมีข้อความที่เป็นรูปแบบของภาษา Html ที่เราเขียนลงไปผ่านการใช้คำสั่ง write ในภาษา python2.x  โดยภาษา Html ที่ได้มีดังนี้

<html>
<head>
<title>Tatchagon Koonkoei</title>
</head>
<body bgcolor="#76EE00">
<center><font size="6" color="#00008B">Profile</font></center><br><br><br>
<font size="4" color="#00008B">My name is :</font>
<font size="4" color="#F5FFFA"><b>Tatchagon Koonkoei</b></font><br><br>
<font size="4" color="#00008B">My student ID is :</font>
<font size="4" color="#F5FFFA"><b>5501012630133</b></font><br><br>
<font size="4" color="#00008B">Birthday :</font>
<font size="4" color="#F5FFFA"><b>June 2, 1993</b></font><br><br>
<font size="4" color="#00008B">Gender :</font>
<font size="4" color="#F5FFFA"><b>Male</b></font><br><br>
<font size="4" color="#00008B">Hometown :</font>
<font size="4" color="#F5FFFA"><b>Thamuang Kanchanaburi Thailand</b></font><br><br>
<font size="4" color="#00008B">Religious Views :</font>
<font size="4" color="#F5FFFA"><b>Buddhism</b></font><br><br>
<font size="4" color="#00008B">Email :</font>
<font size="4" color="#F5FFFA"><b>o_k_t@hotmail.com</b></font><br><br>
<font size="4" color="#00008B">Facebook :</font>
<font size="4" color="#F5FFFA"><b>http://facebook.com/tatchagon</b></font><br><br>
<font size="4" color="#00008B">Education :</font><br>
<font size="4" color="#00008B"><dd>    Primary Education :</font>
<font size="4" color="#F5FFFA"><b>Taladsumrong School</b></font><br>
<font size="4" color="#00008B"><dd>    Secondary Education :</font>
<font size="4" color="#F5FFFA"><b>Srinagarindra The Princess Mother School Kanchanaburi</b></font><br>
<font size="4" color="#00008B"><dd>    University Education :</font>
<font size="4" color="#F5FFFA"><b>King Mongkut's University of Technology North Bangkok</b></font><br>
</body>

</html>

สามารถศึกษาข้อมูลภาษา Html เพิ่มเติมได้จาก เกร็ดความรู้ภาษา Html
ตัวอย่างเมื่อเปิดไฟล์ Html ที่ได้จากการ Run  work1_2.html



3.การสร้างไฟล์ Html หลายๆ ไฟล์แล้วทำให้สามารถลิงค์กันได้  ด้วยภาษา Python 2.x
           โค้ดด้านล่างเป็นโค้ดในภาษา Python 2.7  ซึ่งใช้สำหรับการสร้างไฟล์แบบ html เพื่อแสดงข้อมูลส่วนตัว  ที่มีการเชื่อมต่อกันผ่าน Link เพื่อเชื่อมโยงข้อมูลต่างๆ เข้าด้วยกัน

f=open('work1_3.html','w')

f.write('<html>\n')
f.write('<head>\n')
f.write('<title>Tatchagon Koonkoei')
f.write('</title>\n')
f.write('</head>\n')
f.write('<body bgcolor="#76EE00">\n')
f.write('<center><font size="6" color="#00008B">Profile</font></center><br><br><br>\n')
f.write('<a href=./data9.html><font size="4" color="#00008B">My name :</font></a><br>\n')
f.write('<a href=./data8.html><font size="4" color="#00008B">My student ID :</font></a><br>\n')
f.write('<a href=./data7.html><font size="4" color="#00008B">Birthday :</font></a><br>\n')
f.write('<a href=./data6.html><font size="4" color="#00008B">Gender :</font></a><br>\n')
f.write('<a href=./data5.html><font size="4" color="#00008B">Hometown :</font></a><br>\n')
f.write('<a href=./data4.html><font size="4" color="#00008B">Religious Views :</font></a><br>\n')
f.write('<a href=./data3.html><font size="4" color="#00008B">Email :</font></a><br>\n')
f.write('<a href=./data2.html><font size="4" color="#00008B">Education :</font></a><br>\n')
f.write('<a href="http://facebook.com/tatchagon"><font size="4" color="#00008B">My Facebook :</font></a><br><br>')
f.write('</body>\n')
f.write('</html>\n')
f.close()

str_temp2="""
    <html>
    <head>
    <title>My Education</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Education :</font><br>
        <font size="4" color="#00008B"><dd>    Primary Education :</font>
        <font size="4" color="#F5FFFA"><b>Taladsumrong School</b></font><br>
        <font size="4" color="#00008B"><dd>    Secondary Education :</font>
        <font size="4" color="#F5FFFA"><b>Srinagarindra The Princess Mother School Kanchanaburi</b></font><br>
        <font size="4" color="#00008B"><dd>    University Education :</font>
        <font size="4" color="#F5FFFA"><b>King Mongkut\'s University of Technology North Bangkok</b></font><br><br>
    </body>
    </html>
"""
f2=open('data2.html','w')
f2.write(str_temp2)
f2.close()

str_temp3="""
    <html>
    <head>
    <title>My Email</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Email :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>o_k_t@hotmail.com</b></font>
    </body>
    </html>
"""
f3=open('data3.html','w')
f3.write(str_temp3)
f3.close()

str_temp4="""
    <html>
    <head>
    <title>Religious Views</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Religious Views :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>Buddhism</b></font>
    </body>
    </html>
"""
f4=open('data4.html','w')
f4.write(str_temp4)
f4.close()

str_temp5="""
    <html>
    <head>
    <title>My Hometown</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Hometown :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>Thamuang Kanchanaburi Thailand</b></font>
    </body>
    </html>
"""
f5=open('data5.html','w')
f5.write(str_temp5)
f5.close()

str_temp6="""
    <html>
    <head>
    <title>My Gender</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Gender :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>Male</b></font>
    </body>
    </html>
"""
f6=open('data6.html','w')
f6.write(str_temp6)
f6.close()

str_temp7="""
    <html>
    <head>
    <title>My Birthday</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">Birthday :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>June 2, 1993</b></font>
    </body bgcolor="#76EE00">
    </html>
"""
f7=open('data7.html','w')
f7.write(str_temp7)
f7.close()

str_temp8="""
    <html>
    <head>
        <title>My Student ID</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">My student ID is :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>5501012630133</b></font>
    </body>
    </html>
"""
f8=open('data8.html','w')
f8.write(str_temp8)
f8.close()

str_temp9="""
    <html>
    <head>
        <title>My Name</title>
    </head>
    <body bgcolor="#76EE00">
        <font size="4" color="#00008B">My name is :</font><br>
        <font size="4" color="#F5FFFA"><b><dd>Tatchagon Koonkoei</b></font>
    </body>
    </html>
"""
f9=open('data9.html','w')
f9.write(str_temp9)
f9.close()

print "DONE..."

ตัวอย่างเมื่อทำการ RUN