ITeye博客

诗意的栖居

诗意的栖居 · 共 112 篇文章

IMPDP & EXPDP

expdp介绍 数据泵工具导出的步骤: 1、创建DIRECTORY create directory dir_dp as 'D:\oracle\dir_dp'; 2、授权 Grant read,write on directory dir_dp to lttfm; --查看目录及权限 SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1; 3、执行导出 exp…

2014-05-19 21:42 · Database · 评论(0)

sqlite3 命令

sqlite3 dbname请在db所在目录执行该命令,否则会自动创建一个新的资料库。 一、数据库基础数据表(SQLITE_MASTER) select * from SQLITE_MASTER; 通过select查询该表,该表保存数据库中保存的表结构等基础内容; 二、sqlite3特殊命令 所有sqlite3特殊命令都是以“.”开始的,当用户输入整行数据的时候,sqlite3自动认为是正常的SQL命令;当以“.”开始的行时,sqlite3将认为其为特殊命令操作。 1、改变查询显示数据模式: .mode MODE // 修改查询结果时的显示方式 .mode MODE // 修改查询结果时的显…

2012-11-21 17:15 · Database · 评论(0)

pickle 模块

持久性就是指保持对象,甚至在多次执行同一程序之间也保持对象。通过本文,您会对 Python对象的各种持久性机制(从关系数据库到 Python 的 pickle以及其它机制)有一个总体认识。另外,还会让您更深一步地了解Python 的对象序列化能力。 什么是持久性? 持久性的基本思想很简单。假定有一个 Python 程序,它可能是一个管理日常待办事项的程序,您希望在多次执行这个程序之间可以保存应用程序对象(待办事项)。换句话说,您希望将对象存储在磁盘上,便于以后检索。这就是持久性。要达到这个目的,有几种方法,每一种方法都有其优缺点。 例如,可以将对象数据存储在某种格式的文本文件中,譬如 CSV…

2012-11-15 16:44 · Python笔记 · 评论(0)

python copy and deepcopy

a=,(3,5),123,] b=copy.copy(a) b , (3, 5), 123, ] b=456 b , (3, 5), 456, ] a , (3, 5), 123, ] a之所以没有变,是因为b修改的是不可变对象。 拷贝了一个不可变的对象的引用, 修改你得到的变量只会让该变量的引用指向一个新的对象, 别指望还能改变原来的变量的引用所指向对象的值。 b=0 a , (3, 5), 123, ] b , (3, 5), 456, ] copy.copy只是复制的a本身,a里面的对象并没有被复制,还是引用的。等于属于浅copy c=copy.deepcopy(a) a , (3, …

2012-11-15 14:51 · Python笔记 · 评论(0)

python 常用模块

python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的。 常用的libraries(modules)如下: 1)python运行时服务 copy: copy模块提供了对复合(compound)对象(list,tuple,dict,custom class)进行浅拷贝和深拷贝的功能。 pickle: pickle模块被用来序列化python的对象到bytes流,从而适合存储到文件,网络传输,或数据库存储。(pickle的过程也被称serializing,marshalling或者flattening,pi…

2012-11-15 10:19 · Python笔记 · 评论(0)

SHELL 读不到文件的最后一行?

读文件时,读不到最后一行,在最后一行后面加了一行空的,就可以读到。 while read line do echo $line fi done < $filename 办法:使用vim编辑了一下被读的文件,就可以了,不过不知道是什么原因

2012-11-06 18:06 · Linux · 评论(0)

字符串变成变量名

使用字符串指代变量名。 比如说,有两个变量 a="bbb"和bbb={"c":1},引用a如何得到{"c":1},也就是a的值'bbb'所代表的变量bbb的值。 一 exec('abc = 5') globals() = 6 setattr( builtins , 'abc', 9) import ('sys')._getframe(0).f_globals = 27 二 a='bbb' bbb={"c":1} exec('a=%s' % a) a {"c": 1} 即可实现

2012-11-02 11:47 · Python笔记 · 评论(0)

关于UnsupportedOperationException异常

我们在使用collection框架code时,会时常遇到UnsupportedOperationException异常,有些人很不了解为什么抛出这个异常,会很郁闷,但是那些只知道code的代码工人不会想这些问题。下面我作一下解释,可能也不是很正确。 其实我们主要的疑惑可能是:java既然提供了这个方法,为什么我们调用要抛出异常,说不支持这个操作。我们先看一段代码: List list1 = new ArrayList(); list1.add("test"); String array = new String; List list2 = Arrays.asList(array); List…

2012-10-31 09:43 · java笔记 · 评论(0)

PYTHON--常用函数(一)

字符串常用函数 replace(string,old,new) 字符串的替换函数,把字符串中的old替换成new。默认是把string中所有的old值替换成new 值,如果给出maxsplit值,还可控制替换的个数,如果maxsplit为1,则只替换第一个old值。 a="11223344" print string.replace(a,"1","one") oneone2223344 print string.replace(a,"1","one",1) one12223344 capitalize(string) 该函数可把字符串的首个字符替换成大字。 import string pri…

2012-08-31 09:47 · Python笔记 · 评论(0)

PYTHON--常用函数(二)

类型转换函数 chr(i) chr()函数返回ASCII码对应的字符串。 print chr(65) A print chr(66) B print chr(65)+chr(66) AB ord(x) ord()函数返回一个字符串参数的ASCII码或Unicode值。 ord("a") 97 ord(u"a") 97 hex(x) hex()函数可把整数转换成十六进制数。 hex(16) '0x10' hex(123) '0x7b' oct(x) oct()函数可把给出的整数转换成八进制数。 oct(8) '010' oct(123) '0173' long(x) long()函数把数字和字…

2012-08-30 16:33 · Python笔记 · 评论(0)

PYTHON--常用函数(三)

eval( expression]) 该参数是一个字符串和可选的 globals和 locals。globals必须是一个字典。locals可以是任何映射对象. x = 1 print eval('x+1') 2 g = {'x':'a','y':'b','z':'c'} eval('x+y+z',g) 'abc' exec(str]):exec语句参数的含义大体与eval相同。它可以接收一组语句的字符串。执行语句。 exec("print 2") 2 exec("3*4") exec("for i in range(0,5): print i,") 0 1 2 3 4 compile( s…

2012-08-30 16:33 · Python笔记 · 评论(0)

No.9 Find the product abc

Q: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. A: #! /usr/bin/env python #coding=utf-8 import math import time ''' …

2012-08-27 10:19 · 算法 · 评论(0)

No.8 The greatest product of five consecutive digits in the 1000-digit numb

Q: Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 6689664895044…

2012-08-23 17:27 · 算法 · 评论(0)

No.7 The 10001st prime number

Q: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? A: import math import time t1 = time.time() def getNum(n): #for i in range(2,int(n/2)): for i in range(2,int(math.sqrt(n))+1): if n % i == 0: return 0 return n …

2012-08-23 16:16 · 算法 · 评论(0)

No.6 The difference between the sum of the squares and the square of the sum

Q: The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is …

2012-08-22 09:52 · 算法 · 评论(0)