
Python
绝尘的绝
作品才是你的名片
展开
-
impala-shell -o a.txt 查询中有中文时报错问题的处理
当使用impala-shell -o a.txt进入impala-shell之后,查询报错:报错情况: Query: select * from dim_sales_deptUnknown Exception : 'ascii' codec can't encode characters in position 559-562: ordinal not in range(128...2016-08-12 10:20:42 · 735 阅读 · 0 评论 -
python中的时间和时间格式转换
1.python中的时间:要得到年月日时分秒的时间: import time#time.struct_time(tm_year=2012, tm_mon=9, tm_mday=15, tm_hour=15, tm_min=1, tm_sec=44, tm_wday=5, tm_yday=259, tm_isdst=0)print time.localtime() #返回tupl...2012-09-15 15:11:43 · 1278 阅读 · 0 评论 -
python文档自译:os模块-02【目录概览】
15.1.1. Process ParametersThese functions and data items provide information and operate on the current process and user.15.1.1. 进程参数这些函数和数据项,可为用户和当前进程,提供信息和操作。 15.1.2. File Object Cr...2013-04-25 00:53:50 · 81 阅读 · 0 评论 -
python文档自译:os模块-01【说明部分】
15.1. os — Miscellaneous operating system interfacesThis module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if y...2013-04-25 00:10:45 · 126 阅读 · 0 评论 -
python类继承中构造子的调用
python面向对象中的继承关系中,子类对父类的构造方法的调用有两种方法:父类名.__init__(self,参数) #注意名字是父类super(本子类名,self)__init__(其他参数) #注意名字是本身子类,而且init后是self之外的参 例子程序代码:# -*- coding:utf-8 -*- class Person(object):...2012-07-17 11:47:47 · 103 阅读 · 0 评论 -
一步一例学python--读取控制台输入记录到文件
从今天起,多写些小例子,锻炼自己,从大家都不鸟的小段代码开始。今天弄一个从控制台输入信息,然后记录到当前路径下的一个固定文件中。很简单: import osfname=raw_input('Enter file name:')myf= open(fname,'w')while True: text=raw_input('Enter text[exit to q...2012-03-07 15:49:00 · 845 阅读 · 0 评论 -
python的文件和系统属性
os模块跨平台 os.linesep // '\r\n' windows '\r' POSIX系列os.sep // '\\' '/'os.pathsep // ';' ':'os.curdir // '.' os.pardir // '..' ...2012-03-07 15:11:38 · 137 阅读 · 0 评论 -
python 文件相关函数
os模块:os.path.exists(path) -->bool #(path)文件或者目录存在os.path.abspath(path) -->str #(path)返回文件或者目录的绝对路径# 下面几个顾名思其义吧os.path.isfile(path) -->boolos.path.isdir...2012-02-25 18:00:44 · 114 阅读 · 0 评论 -
python 模块和布局
写一个Demo:大致7个部分:#1.起始行 #2.模块文档 #3.模块导入#4.声明模块变量 #5.类声明 #6.函数声明 #7.主程序 #!/usr/bin python #1"Here are module docs" #2import sys,os #3point = 20 #4class Demo...2012-02-25 14:41:39 · 97 阅读 · 0 评论 -
python解析xml【简易】
python解析xml文件:1.xml文件示例如下:cfg.xml<?xml version="1.0"?><tree><probe> <first_node> <name>HanMeimei</name> <gender>female</gende2012-06-26 16:41:17 · 122 阅读 · 0 评论 -
python基础:用apply使用元祖和列表调用函数
python基础:内置模块,用apply使用元祖和列表调用函数 def my_fuc(a, b): print a, batuple=(30,10)alist= ['Hello','World!']apply(my_fuc,atuple)apply(my_fuc,alist) 输出:D:\py>python buildin.py30 10...2012-06-18 11:05:29 · 374 阅读 · 0 评论 -
python插入数据库mysql
#-*- coding:utf-8 -*-import MySQLdb#alter table test add index prefixIdx_test(ext(2));//前缀索引try: # 1.初始化连接 conn=MySQLdb.connect(host='localhost',user='root',passwd='1234',port=3306) # 2.使...原创 2014-10-29 17:05:43 · 224 阅读 · 0 评论