py2exe

Comments   0   Date Arrow  February 8, 2009 at 1:59am   User  by pichai

py2exe ช่วยแปลง python ไฟล์ให้เป็น exe ไฟล์เพื่อที่จะรันใน window ได้โดยไม่ต้องลง python

Download
Tutorial

Tagged   Talk  delicious  Comments  Add Your Comment

Function str (Example Python Built-in Functions)

Comments   0   Date Arrow  November 28, 2008 at 9:37am   User  by pichai

str(object)
แปลง object ที่ส่งเข้าไปกลับมาในรูปแบบ string
>>> str(123)
‘123′
>>> str(50.99)
‘50.99′
>>> str(['Hello','World'])
“['Hello', 'World']”

Tagged   Talk  delicious  Comments  Add Your Comment

Function ord (Example Python Built-in Functions)

Comments   0   Date Arrow  November 7, 2008 at 11:12am   User  by pichai

ord(i)
คืนตัวเลขที่มีค่า Unicode เท่ากับตัวอักษรที่ส่งไปซึ่งจะตรงข้ามกับฟังก์ชั่น chr()
>>> ord(’a')
97
>>> ord(’z')
122

Tagged   Talk  delicious  Comments  Add Your Comment

Function chr (Example Python Built-in Functions)

Comments   0   Date Arrow  November 6, 2008 at 9:37am   User  by pichai

chr(i)
คืนตัวอักษรที่มีค่า ACSII เท่ากับ i ซึ่งจะตรงข้ามกับฟังก์ชั่น ord() โดยจะรับค่าตัวเลข 0 ถึง 255 นอกเหนือจากนั้นจะเกิดข้อผิดพลาด
>>> chr(97)
‘a’
>>> chr(122)
‘z’

Tagged   Talk  delicious  Comments  Add Your Comment

Function abs (Example Python Built-in Functions)

Comments   0   Date Arrow  November 5, 2008 at 2:55pm   User  by pichai

abs(x)
จะคืนคืนค่าสัมบูรณ์ของตัวเลข
>>> abs(-9)
9
>>> abs(9)
9

Tagged   Talk  delicious  Comments  Add Your Comment

Function any (Example Python Built-in Functions)

Comments   0   Date Arrow  November 3, 2008 at 10:55am   User  by pichai

any(iterable)
จะคืนค่า True ถ้าแต่ละ elements ใน iterable เป็น True อย่างน้อย 1 ตัว
>>> a = [True,False]
>>> any(a)
True
>>> a = [False,0]
>>> any(a)
False

Tagged   Talk  delicious  Comments  Add Your Comment

Function all (Example Python Built-in Functions)

Comments   0   Date Arrow  October 31, 2008 at 9:39am   User  by pichai

all(iterable)
จะคืนค่า True ถ้าแต่ละ elements ใน iterable เป็น True ทั้งหมด
>>> a = [True,False]
>>> all(a)
False
>>> a = [True,1]
>>> all(a)
True

Tagged   Talk  delicious  Comments  Add Your Comment

string does not support item assignment

Comments   0   Date Arrow  June 20, 2008 at 2:43pm   User  by pichai

a = ‘abc’
a[1] = ‘x’
print a
Have Error
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in <module>
a[1] = ‘x’
TypeError: ’str’ object does not support item assignment
Change to
a = ‘abc’
a = a[:1] + ‘x’ + a[2:]
print a

Tagged   Programming · Python  delicious  Comments  Add Your Comment