pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
2008-12-21
pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
¹Ø¼ü×Ö: pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
pythonÀàÐÍת»»
Java´úÂë
º¯Êý ÃèÊö
int(x [,base ]) ½«xת»»ÎªÒ»¸öÕûÊý
long(x [,base ]) ½«xת»»ÎªÒ»¸ö³¤ÕûÊý
float(x ) ½«xת»»µ½Ò»¸ö¸¡µãÊý
complex(real [,imag ]) ´´½¨Ò»¸ö¸´Êý
str(x ) ½«¶ÔÏó x ת»»Îª×Ö·û´®
repr(x ) ½«¶ÔÏó x ת»»Îª±í´ïʽ×Ö·û´®
eval(str ) ÓÃÀ´¼ÆËãÔÚ×Ö·û´®ÖеÄÓÐЧPython±í´ïʽ,²¢·µ»ØÒ»¸ö¶ÔÏó
tuple(s ) ½«ÐòÁÐ s ת»»ÎªÒ»¸öÔª×é
list(s ) ½«ÐòÁÐ s ת»»ÎªÒ»¸öÁбí
chr(x ) ½«Ò»¸öÕûÊýת»»ÎªÒ»¸ö×Ö·û
unichr(x ) ½«Ò»¸öÕûÊýת»»ÎªUnicode×Ö·û
ord(x ) ½«Ò»¸ö×Ö·ûת»»ÎªËüµÄÕûÊýÖµ
hex(x ) &nbs
Ïà¹ØÎĵµ£º
ÏеÄÎÞÁľͿ´ÁËÒ»µã¹ØÓÚpythonµÄ»ù´¡ÖªÊ¶£¬µ±Ê±Ò²²»ÖªµÀpythonºÍperlÖ®¼äÕùÂÛµÄÕâôµÄ¼¤ÁÒ£¨Ö÷ÒªÊǵ±Ê±²»ÖªµÀperlÕâ¸öÓïÑÔµÄÐÔÖÊ),ËùÒÔÖ±½Ó¾Í¿´ÁËpython£¬ÏÂÃæÊÇÎҵĵÚÒ»¸öÓÃpythonдµÄС³ÌÐòÔ´Â룬ϣÍûÅóÓÑÃǶà¶àÖ¸½Ì£¬ÓÐʲôÎÊÌâ´ó¼Ò¾¡¹ÜÖ¸Õý£¬ÔÚ´ËÏÈлл´ó¼ÒÁË¡£
[code]
#!/usr/bin/python
import sys, os, re
impor ......
Ò»¡¢Ê¹ÓÃPythonÐèÒªÖªµÀµÄ
ÔÚ Windows ÉÏ£¬°²×° Python ÓÐÁ½ÖÖÑ¡Ôñ¡£
1¡¢ActiveState ÖÆ×÷µÄ ActivePython ÊÇרÃÅÕë¶Ô Windows µÄ Python Ì×¼þ£¬Ëü°üº¬ÁËÒ»¸öÍêÕûµÄ Python ·¢²¼¡¢Ò»¸öÊÊÓÃÓÚPython ±à³ÌµÄ IDE ÒÔ¼°Ò»Ð© PythonµÄ Windows À©Õ¹£¬ÌṩÁËÈ«²¿µÄ·ÃÎÊ Windows APIs µÄ·þÎñ£¬ÒÔ¼° Windows×¢²á±íµÄ×¢²áÐÅÏ¢¡£ËäÈ ......
Programming Python, 2nd Edition (O'Reilly)
http://www.osbbs.com/dl/Programming Python, 2nd Edition (O'Reilly).chm
ºÜÈ«ºÜ¾µäÁËpythonѧϰÈëÃÅ×ÊÁÏ
OReilly - Learning Python:
http://www.osbbs.com/dl/OReilly - Learning Python.chm
......
python stringºÍPyQtµÄQStringµÄÇø±ð ÒÔÏÂÔÚPython2.6ºÍPyQt4.4.4 for
Python2,6»·¾³ÏÂÌÖÂÛ£º PythonÖÐÓÐÁ½ÖÖÓйØ×Ö·ûµÄÀàÐÍ£ºPython string objectºÍPython Unicode
object¡£Ö÷ҪʹÓÃPython string object½øÐÐÊý¾ÝÊäÈëÊä³ö¡£ PyQtÖÐÓëÖ®Ïà¶ÔÓ¦µÄ×Ö·ûÓйØÀà
python stringºÍPyQtµÄQStringµÄÇø±ð
ÒÔÏÂÔÚPython2.6ºÍPyQt4 ......
Öð²½Ñݽø
f=open('/etc/motd','r')
longest=0
while True:
lineLen=len(f.readline().strip())
if not lineLen: break
if lineLen > longest:
longest=lineLen
f.close()
return longest
ÎÊÌâ£ºÒ»Ö±Õ¼Ó ......