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
Ïà¹ØÎĵµ£º
#½«Ò»Ð©ÀàÐ͵ÄÎļþѹËõΪ7z.py
#for folder all file do 7z
import os
import sys
import distutils.file_util
def ImportOkFile():
if(os.path.isfile("D:\\Records\\½«Ò»Ð©ÀàÐ͵ÄÎļþѹËõΪ7z_record.txt")==False):
f=open("D:\\Reco ......
ÎÊÌâÃèÊö
ÔÚ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', ......
import win32com.client
store = win32com.client.Dispatch('CAPICOM.Store')
# ´ò¿ªÖ¤Êé´æ´¢Çø
# 2 -> CAPICOM_CURRENT_USER_STORE
# 0 -> CAPICOM_STORE_OPEN_READ_ONLY
store.Open(2, "My", 0)
# ²éÕÒÓÐЧ֤Êé
# 12 -> CAPICOM_CERTIFICATE_FIND_KEY_USAGE
# 0x00000080 -> CAPICOM_DIGITAL_SIGNATU ......
#coding=utf-8
from math import sqrt,cos,sin
import Image, ImageDraw
class SpireShape(object):
def __init__(self, draw):
self.draw = draw
self.line_width = 1
& ......