摘要: #coding:gbkimport xlrdimport cx_Oraclefields = []data = []table_name = 'ygl_test1'wb = xlrd.open_workbook("清单.xlsx")sheet1 = wb.sheet_by_index(0)#取第一行做数库字段名title = sheet1.row_values(0)#取第二行开始做数据for ro... 阅读全文
posted @ 2015-02-06 16:52 阳光树林 阅读(414) 评论(0) 推荐(0) 编辑
摘要: #coding:gb18030import cx_Oracleimport xlsxwriterimport timeimport sys reload(sys) sys.setdefaultencoding("gb18030")con = cx_Oracle.connect("user/user123@user")cursor = con.cursor()query1 = cursor.exec... 阅读全文
posted @ 2015-02-06 16:51 阳光树林 阅读(666) 评论(0) 推荐(0) 编辑
摘要: Windows下Python添加库(模块)路径 用Python已经有一段时间了,自己也写了一些实用的库。为了更加方便的使用这些库,需要将他们的路径添加到Python的库路径中去。经过查找资料,总结了如下两种方法:动态的添加库路径。在程序运行过程中修改sys.path的值,添加自己的库路径import syssys.path.append(r'your_path') 在Python安装... 阅读全文
posted @ 2015-02-06 16:49 阳光树林 阅读(812) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-import osimport sysimport stringnewline, s = ("", "")try: f = open(u"简易记账.csv")except IOError: print "文件不存在!".decode('utf8').encode('gbk') sys.exit()f1 = open(u"结果.txt"... 阅读全文
posted @ 2015-02-06 16:48 阳光树林 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 你可能不知道的 30 个 Python 语言的特点技巧 1 介绍从我开始学习Python时我就决定维护一个经常使用的“窍门”列表。不论何时当我看到一段让我觉得“酷,这样也行!”的代码时(在一个例子中、在StackOverflow、在开源码软件中,等等),我会尝试它直到理解它,然后把它添加到列表中。这篇文章是清理过列表的一部分。如果你是一个有经验的Python程序员,尽管你可能已经知道一... 阅读全文
posted @ 2015-02-06 16:47 阳光树林 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 版本一:#coding:utf-8import re#把文档中的单引号替换为2个单引号def replacestr(matched): matchedstr = matched.group() x = matchedstr.replace("'", "''") return xdef main(): f_sql = open('fzt_dd.sql', 'r') sq... 阅读全文
posted @ 2015-02-06 16:45 阳光树林 阅读(280) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8a = '''update ph_daily t set t.{0} = decode((to_number(to_char(sysdate-2,'DD'))*t.{1}),0,0,t.{2}/(to_number(to_char(sysdate-2,'DD'))*t.{1})); '''b = ('N5S_M_TARGET','N5S_M','N5S_M_RATE','... 阅读全文
posted @ 2015-02-06 16:41 阳光树林 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 版本一:#coding:utf-8import Queueimport threadingimport timeimport urllib2import reexitFlag = 0class myThread (threading.Thread): def __init__(self, threadID, name, q, txt_dict): threading.Threa... 阅读全文
posted @ 2015-02-06 16:39 阳光树林 阅读(195) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf8 -*-from bs4 import BeautifulSoupimport os, sys, urllib2, urllibimport thread, threadingclass downloader(threading.Thread): """docstring for downloader""" def __init__(self, url... 阅读全文
posted @ 2015-02-06 16:34 阳光树林 阅读(243) 评论(0) 推荐(0) 编辑
摘要: sublime text3 运行python配置 一、1. 在工具栏点击tools,打开bulid system->new bulid system。2. 修改以下内容并保存{"cmd": ["python", "-u", "$file"],"path":"c:/Python27","file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)","... 阅读全文
posted @ 2015-02-06 16:33 阳光树林 阅读(657) 评论(0) 推荐(0) 编辑