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 º¯ÊýµÄ"µ÷ÖÆ"£¬ÊÇÖ¸¶ÔÆä×ö³öºÏºõÐèÇóµÄÉèÖ᣾ßÌåµÄµ÷ÖÆ·½·¨£¬Êǽ«Æä²ÎÊýÉèΪ¹Ì¶¨Öµ£¨³£Êý£©¡£
É趨µ¥Ò»µÄ²ÎÊýÖµ
ÔÏȵĺ¯ÊýÊÇÕâÑùµÄ£º
>>> def foo(cooked, standard):
... print "foo called with cooked: %s, standard: %s" % \
... (cooked, standard)
µ÷ÓÃËü£º
>>> foo('a', ......
Python±ê×¼¿â-randomÄ£¿é
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉú³ÉÆ÷. »ù±¾Ëæ»úÊýÉú³ÉÆ÷(»ùÓÚ Wichmann ºÍ Hill , 1982 µÄÊýѧÔËËãÀíÂÛ) ¿ÉÒÔͨ¹ýºÜ¶à·½·¨·ÃÎÊ, Èç Example 2-29 Ëùʾ. 2.17.0.1. Example 2-29. ʹÓà random Ä£¿é»ñµÃËæ»úÊý×Ö File: random-example-1.py import random for i i
¡¡¡¡
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉ ......
pythonµÄeggÎļþÓеãÏñjavaÖеÄjarÎļþ£¬ÊÇÒ»¸ö¹¤³Ì´ò°üÎļþ£¬±ãÓÚ°²×°²¿Ê𣬽ö´ËÒ»µã£¬¸ø¶àÉÙpythoner´øÀ´Á˶àÉÙ¼¤¶¯¡£
ÈçºÎÖÆ×÷eggÎļþÄØ£¿see¹Ù·½Îĵµhttp://peak.telecommunity.com/DevCenter/PythonEggs£¬
µ½http://pypi.python.org/pypi/setuptoolsÏÂÔØsetuptools°ü£¬È»ºó°²×°£º
python setup.py
1.ÖÆ×÷eggÎļþ
......
µ÷ÓÃÒ»¸ö¿ØÖÆÌ¨³ÌÐò£¬»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬»ò°ÑËüµÄ±ê×¼Êä³öÖØ¶¨Ïòµ½½çÃæÉÏ£¬ÕâÀïÖ»½éÉÜÈçºÎ»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬ÒòΪÔÀí¶¼Ò»ÑùµÄ¡£
ʹÓÃ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" #ÕýÔò±í´ïʽĩβÒÔ\ ......