随笔分类 - python
摘要:函数释义 Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实现简单的ftp客户端,用于上传或下载文件,函数列举如下 FTP.quit()与FTP.close()的区别 FTP.quit():发送QUIT命令给服务器并关闭掉连接。这是一个比较“缓和”的关闭连接方式,但是如果
阅读全文
摘要:import datetime #日期初始化: d1 = datetime.datetime(2005, 2, 16) d2 = datetime.datetime(2004, 12, 31) #日期相减: print (d1 - d2).days starttime = datetime.datetime.now() endtime = datetime.datetime.now() pr...
阅读全文
摘要:import psycopg2 conn = psycopg2.connect(database="baoxin", user="odoo", password="odoo", host="127.0.0.1", port="5432") cur = conn.cursor() cur.execute("CREATE TABLE test(id serial PRIMARY KEY, num i...
阅读全文
摘要:错误是由于从os模块引入了所有的函数导致的,os模块下有一个open函数,接受整型的文件描述符和打开模式,from os import *引入os模块的open函数,覆盖了python内建的open函数,导致错误。删除from os import *这行,然后再根据需要,指定引入os模块下的函数建议
阅读全文
摘要:貌似生成的url有问题,待优化。。。
阅读全文
摘要:# -*- coding=utf-8 -*- import sys import os import os.path import time import urllib.request, urllib.parse, urllib.error from threading import Thread local_proxies = {} class ThreadDownComplete...
阅读全文
摘要:# -*- coding=utf-8 -*- import re import string import urllib, urllib2 import os, sys import multiprocessing def getImageUrls(page): '''获取每个模块下的图片链接''' image_items = {} url_index = '...
阅读全文
摘要:这几天在折腾Python环境,显示把笔记本安装Ubuntu Linux环境系统,然后基本的Python环境都安装完毕之后需要安装传说中在其平台中最好的代码编辑和管理工具PyCharm,于是就根据网上的教程安装,但是在过程中还是会遇到各种的问题,所以今天把整个安装PyCharm过程都整理下来配上自己的
阅读全文
摘要:# -*- coding: utf-8 -*- import math import re import csv import repr def ean_checksum(eancode): """returns the checksum of an ean string of length 13, returns -1 if the string has the wrong lengt...
阅读全文
摘要:第一个图灵机器人接口实例: 第二个图灵机器人接口实例:
阅读全文
摘要:运行结果:叁百肆拾叁元肆角伍分
阅读全文