Python教程
Python教程:包含了所有代写案例以及部分答案
-
python定时执行指定的函数“`python time a function using time.time() and the a @ function decorator tested with Python24 vegaseat 21aug2005 import time def print_timing(func): def wrapper(arg): t1 = time.time() res = func(arg) t2 = time.time() print ̵ … 继续阅读“python 定时执行指定的函数”
:
-
1 #!/usr/bin/env python 2 while True: 3 4 score=int(raw_input(‘please input your score(0-100): ‘)) 5 if score >=90 and score <=100: 6 print ‘your are A type’ 7 elif 80<=score<=89: 8 print ‘you are B type’ 9 elif 70<=score<=79: 10 pr … 继续阅读“python if elif else 使用”
:
-
from html.parser import HTMLParser from urllib.request import urlopen from urllib import parse class LinkParser(HTMLParser): def handle_starttag(self, tag, attrs): if tag == ‘a’: for (key, value) in attrs: if key == ‘href’: newUrl = parse.urljoin(sel … 继续阅读“python精简版搜索引擎”
:
-
服务器端代码“`python –– coding: utf-8 –– import SimpleXMLRPCServer server 上面的程式碼 def Show_me_some_message(sMsg):#從遠端呼叫並且帶入參數 print “I see your call %s” % sMsg return “Received, from client Machine 1” de … 继续阅读“python通过xmlrpc进行远程调用的范例演示”
:
-
#coding:utf-8 class Node(object): def __init__(self, data): self.data = data self.next = None class NodeList(object): def __init__(self, node): self.head = node self.head.next = None self.end = self.head def add_node(self, node): self.end.next = node … 继续阅读“python实现单链表”
:
-
调用sax模块处理xml文件。 #重载了三个方法 #处理xml,主要就是写自己的事件处理类 from xml.sax import * class DengHandler(ContentHandler): def startDocument(self): print("—-开始解析xml文档—-") def endDocument(self): print("—-xml文档解析完毕—-") def startElement(self,nam … 继续阅读“python 使用python3.4解析xml文件(sax、dom、etree)”
:
-
# coding:utf-8 """ 有人问如何遍历取得类的子类或实例 黄哥python远程视频培训班 https://github.com/pythonpeixun/article/blob/master/index.md 黄哥python培训试看视频播放地址 https://github.com/pythonpeixun/article/blob/master/python_shiping.md 咨询qq:1465376564 """ … 继续阅读“python 有人问如何遍历取得类的子类或实例”
:
-
import requests import urllib import urllib2 KEY = ‘d92d20bc1d8bb3cff585bf746603b2a9’ url = ‘http://www.tuling123.com/openapi/api’ req_info = u’讲个笑话’ query = {‘key’: KEY, ‘info’: req_info} headers = {‘Content-type’: ‘text/html’, ‘charset’: ‘utf-8’} # … 继续阅读“python 几行代码就能调用智能接口”
:
-
#coding:utf-8 import socket import threading import time class SkPort(threading.Thread): def __init__(self,ip,port): threading.Thread.__init__(self) self.ip = ip self.port = port def run(self): sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s … 继续阅读“python 查看端口状态的python代码”
:
-
这段代码通过MySQLdb模块连接mysql数据库,然后查询employee表中income字段大于1000的数据输出 #!/usr/bin/python import MySQLdb # Open database connection db = MySQLdb.connect("localhost","testuser","test123","TESTDB" ) # prepare a cursor object … 继续阅读“python通过MySQLdb模块连接查询mysql数据”
: