python Eric µÄʹÓÃ
×î½üʹÓÃpython¹ý³ÌÖУ¬python½çÃæµÄ±à³Ì¹¤¾ßGTK-Python£¬µ«ÊǽçÃæµÄÃÀ¹ÛÐÔ²»ÈçQt-CreatorÖеÄQt-Designer£¬ÎÞ·¨ÊµÏÖÉè¼ÆÊÇÊÓͼ»æÖÆ£¬ÓеãÈÃÈËʧÍû¡£
ÍøÉÏ·¢ÏÖÓÐÈ˽éÉÜpython Eric IDE,±È½ÏºÃÆ棬°²×°ÉÏ¿´¿´°É£º
#yum install eric4
µ«ÊÇн¨µÄ¹¤³ÌÎÞ·¨run,˵ȱÉÙpyuic4£¬ÓÚÊÇ°²×°ÉÏ¿ª·¢°ü
#yum install PyQt4-devel
ÒòΪ֮ǰÎÒ°´×°ÁËqt4.7Àà¿â£¬ËùÒÔÒ»Çж¼ÄÇô˳Æä×ÔÈ»£¬Ð½¨ÁËÒ»¸ö¶Ô»°¿ò£¬ÒòΪpython eric ÖÐǶÈëÁËQt -Designer¹¤¾ß£¬ËùÒÔ»æÖƵĴ°¿Ú±È½ÏÃÀ¹Û£¬Éϵµ´Î£¬ºÇºÇ£¬²»´í£¬±£´æuntitled.uiÎļþ£¬¹Ø±Õdesigner´°¿Ú£¬»Øµ½eric IDE ´°¿Ú·¢ÏÖÔÚsourceÊÓͼ϶àÁËÒ»¸öUi_untitled.pyÎļþ£º
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/fedora11/myPro/eric/untitled.ui'
#
# Created: Mon Mar 8 11:00:42 2010
# by: PyQt4 UI code generator 4.7
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(334, 170)
self.heyButton = QtGui.QPushButton(Dialog)
self.heyButton.setGeometry(QtCore.QRect(60, 100, 85, 27))
self.heyButton.setObjectName("heyButton")
self.pushButton_2 = QtGui.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(200, 100, 85, 27))
self.pushButton_2.setObjectName("pushButton_2")
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(90, 30, 151, 24))
self.lineEdit.setObjectName("lineEdit")
self.dial = QtGui.QDial(Dialog)
self.dial.setGeometry(QtCore.QRect(150, 60, 50, 64))
self.dial.setObjectName("dial")
self.retranslateUi(Dialog)
QtCore.QObje
Ïà¹ØÎĵµ£º
python ûÓÐÊý×éµÄÊý¾Ý½á¹¹
#list ÐòÁÐ
sample_list = [1,2,3,'abc']
#dictionary ×Öµä
sample_dic = {"key":value, 2:3}
#tuple Ö»¶ÁµÄÐòÁÐ
sample_tuple = (1,3,"ab")
Ðò±í
Ðò±íÓÉһϵÁÐÖµÓöººÅ·Ö¸ô¶ø³É
Ðò±íÓë×Ö·û´®Ò»ÑùÊDz»¿É±äµÄ£º²»ÔÊÐí¶ÔÐ ......
ÎÒÖªµÀµÄÒ»ÖÖÔÚ
python
ÖÐ
Singleton mode
µÄʵÏÖÈçÏ£º
class Foo: pass
def
instance():
global inst
try:
inst
except:
inst =
Foo
()
&n ......
ÁÐ±í·½·¨£º
·½·¨
˵Ã÷
append( item )
ÔÚÁбíĩβ²åÈ루item £©
count( element )
·µ»ØelementÔÚÁбíÖгöÏֵĴÎÊý
extend( newlist )
½«newlistµÄÔªËزåÈëÁбíĩβ
index( element )
·µ»ØelementÔÚÁбíÖеÄË÷Òý£¬Èç¹û²»´æÔÚ£¬ÔòÒý·¢ValueErrorÒì³£
insert( index , item )
ÔÚindex ......
µ÷ÓÃÒ»¸ö¿ØÖÆ̨³ÌÐò£¬»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬»ò°ÑËüµÄ±ê×¼Êä³öÖض¨Ïòµ½½çÃæÉÏ£¬ÕâÀïÖ»½éÉÜÈçºÎ»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬ÒòΪÔÀí¶¼Ò»ÑùµÄ¡£
ʹÓÃpython2.5µÄsubprocessÄ£¿éÀ´ÊµÏÖ¡£
import sys
import subprocess
def RunShellWithReturnCode(command, print_output=False,
universal_newline ......
ÏÂÃæÁгöPythonÕýÔò±í´ïʽµÄ¼¸ÖÖÆ¥ÅäÓ÷¨£º
1.²âÊÔÕýÔò±í´ïʽÊÇ·ñÆ¥Åä×Ö·û´®µÄÈ«²¿»ò²¿·Ö
regex=ur"" #ÕýÔò±í´ïʽ
if re.search(regex, subject):
do_something()
else:
do_anotherthing()
2.²âÊÔÕýÔò±í´ïʽÊÇ·ñÆ¥ÅäÕû¸ö×Ö·û´®
regex=ur"\Z" #ÕýÔò±í´ïʽĩβÒÔ\ ......