Python教程
Python教程:包含了所有代写案例以及部分答案
-
#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数据”
:
-
1 C:test [dir] getpath [file] path.py [dir] sub [file] sub_path.py 比如 C:\test目录下还有一个名为sub的目录; C:\test目录下有getpath.py,sub目录下有 sub_path.py,getpath.py调用sub_path.py; 我们在C:\test下执行getpath.py。如果我们在 sub_path.py里面使用sys.path[0],那么其实得到的是getpath.py所在的目录路径“C:\tes … 继续阅读“Python获取脚本所在目录的正确方法”
:
-
首先,到http://pymssql.sourceforge.net/下载pymssql模块,必须安装这个模块才可以用python连接mysql 以下是简单的访问代码,需要注意字符集 # -*- coding:gbk -*- import pymssql #创建一个数据库连接,host是服务器的ip地址,如果是本机可以用".",user是访问用户名,password是密码,database是数据库名,比ADO的连接似乎简单一些 conn=pymssql.connect(hos … 继续阅读“python连接sql server数据库”
:
-
[Python]代码 “` python def maopao(list): for i in range(0, len(list)): for j in range(len(list) – 1, i – 1, -1): if list[j] < list[j-1]: temp = list[j] list[j] = list[j-1] list[j-1] = temp #printResult(list) def printResult(list): … 继续阅读“python 冒泡排序”
:
-
运行结果 ——————————————————————————– 庄家:> 准备开局,请各位玩家准备进入! 庄家:> 下注规则:各位玩家投注金额需是$5的倍数(如,$5/$50/$100等),多少我都能赔起! 系统:> 是否加入这局(y/n,回车默认y,5秒后默认n,退出输入q)?: 系统:> 玩家余额 $18705 系统:> 玩家总下注金额 $0 系统:> … 继续阅读“python RedDog文字式猜点数游戏”
: