PythonͨѶ²¾
ÕâÁ½ÌìÔÚѧϰpythonÓïÑÔ£¬Ò²Ñ§×ÅдÁ˸öͨѶ²¾£¬Á·Ï°ÈëÃÅÏ£¡
¹¦ÄܰüÀ¨ÒÔÏ£º
1¡¢Ôö¼ÓÒ»Ìõ¼Ç¼
2¡¢É¾³ýÒ»Ìõ¼Ç¼
3¡¢ÐÞ¸ÄÒ»Ìõ¼Ç¼
4¡¢²éѯһÌõ¼Ç¼
5¡¢ÏÔʾÕû¸öͨѶ²¾
6¡¢°ïÖúÌáʾ
7¡¢°æ±¾ÏÔʾ
8¡¢Í˳öµÈ
Ê×ÏȽ¨Á¢Ò»¸öPersonÀ࣬¼´Person.pyÎļþ£¬ÓÃÀ´±£´æÁªÏµÈ˼Ǽ£º
class Person:
def __init__(self, name, email, phone):
self.name = name
self.email = email
self.phone = phone
½ÓÏÂÀ´ÊǸöaddressBook.pyÎļþ£¬ÓÃÒÔʵÏÖÉÏÃæÌáµ½µÄ¹¦ÄÜ£¬ÕâÀïÓÃÁË´æ´¢Æ÷£¬½«¶ÔÏó±£´æÔÚÎļþÖÐÀ´ÊµÏÖÊý¾Ý´æ´¢¡£
import cPickle as p
from Person import Person
filename = 'addressBook.data'
while True:
order = raw_input('/////////////////////////////////////\nEnter your order:')
#add
if order == 'add':
addName = raw_input('Enter name:')
f = file(filename)
dic = p.load(f)
if dic.has_key(addName) == False:
dic[addName] = Person(addName, raw_input('Enter email:'), raw_input('Enter phone:'))
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#delete
elif order == 'del':
delName = raw_input('Enter name who you will delete:')
f = file(filename)
dic = p.load(f)
if dic.has_key(delName):
del dic[delName]
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#modify
elif order == 'mod':
modName = raw_input('Enter name who you will modify:')
f = file(filename)
dic = p.load(f)
if dic.has_key(modName):
dic[modName] = Person(modName, raw_input('Enter email:'), raw_input('Enter phone:'))
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#search
elif order == 'search':
schName = raw_input('Enter name who you will search:')
f = file(filename)
dic = p.load(f)
if dic.has_key(schName):
psch = dic[schName]
print psch.name
print psch.email
Ïà¹ØÎĵµ£º
http://www.autohotkey.com/forum/topic53773.html
Q:I am searching for is a way to execute AHK commands from a Python script. Is this possible?
A:Yes. Here is an example.
tested with python2.6, requires AutoHotkey.dll in the working directory or path...
ahkpython.py:
#Persistent
dllc ......
ÓÉÓÚ¹¤×÷ÐèÒª£¬ÓÖҪѧϰеĿª·¢ÓïÑÔ-Python£¬ ÓïÑÔѧ¹ý¼¸ÖÖÁË£¬ ¸Ð¾õ»¹ÊÇÓкöàÏàËÆµÄµØ·½£¬ Õâ¸öPython¸Ð¾õ¾Í¸úJavaÓкöàÏàͨµÄµØ·½£¬ Ê×ÏÈÄã¿ÉÒÔÔÚEclipseÉÏͨ¹ýÅäÖúóÀ´¿ª·¢Python¡£ÕâÀïÎÒÌý´ÓÁËÀÏ´óµÄ½¨Ò飬ÅäÖÃÁËÒ»¸öFlexBuilder ×÷ΪPythonµÄIDE½øÐпª·¢¡£
Ŀǰ¸Õ¿ªÊ¼Ñ§Ï°PythonµÄ»ù±¾Óï·¨£¬ ½ñÌìÖ÷Òª¿´ÁËÒ»ÏÂPyth ......
ÎÊÌâÃèÊö
ÔÚC++ºÍPython»ìºÏ±à³ÌÖУ¬ÔÚÈí¼þ·¢²¼µÄʱºòÐèÒª½«pythonµÄ½âÊÍÆ÷´ò°üµ½°²×°³ÌÐòÖУ¬ÎªÁËÌá¸ßÓû§ÌåÑ飬ÎÒÃÇÐèÒªÈÃÓû§¸Ð¾õ²»µ½pythonµÄ°²×°£¬Èç¹ûÓû§ÒѾ°²×°ÓÐpythonµÄ»·¾³£¬ÎÒÃÇÒ²Òª±£Ö¤²»Ó°ÏìÏÖÓеÄϵͳ¡£
½â¾ö·½°¸
ÔÚPython2.5ÒÔºó£¬pythonÖ§³Ö´ÓzipÎļþÖжÁÈ¡python½Å±¾Îļþ£¬Ö§³Ö¶ÁÈ¡py£¬pyc£¬pyo£¬²»Ö ......
Python µÄÒì³£´¦Àí»úÖÆ
Python´úÂë
try:
raise Exception("a", "b")
except Exception,e:
print e
finally:
print "final"
('a', ......