2012年9月19日

【python】只对文件open,不close的后果

摘要: 这个问题的主要目的是研究当程序中没有显示close掉已经open的文件,那么这个文件会在什么时候被close掉?已经知道在C++中,打开的文件句柄没有被close掉的话,那这个句柄只会在程序退出时才会被释放掉,那么在python是否也是这样的呢?接下来做个实验:1.有如下代码:import osclass OpenFileTest: def openfile(self, filePath): handle = open(filePath, 'wb') passif __name__ == "__main__": t = OpenFileTest(... 阅读全文

posted @ 2012-09-19 12:01 jeJee 阅读(9559) 评论(0) 推荐(0)

2012年9月10日

【Linux】CollabnetSVN安装

摘要: 使用 rz 命令上将svn安装包到Linux系统;假设安装包的路径为RPM_PATH,使用命令 "Rpm –ivh RPM_PATH" 来安装;使用 "whereis svn" 来获取 svn 的路径;如:"/opt/CollabNet_Subversion/bin/svn";在PATH环境变量中添加svn的路径("/opt/CollabNet_Subversion/bin",注意不要最后面的svn);添加环境变量的方法为:vi /etc/profile在文件最后一行添加:exportPATH=/opt/Colla 阅读全文

posted @ 2012-09-10 10:56 jeJee 阅读(237) 评论(0) 推荐(0)

2012年9月7日

【C/C++】设置磁盘剩余空间

摘要: const DWORD g_sysReserveBytes = 5 * 1024;const tstring g_diskEmulatorFileName = _T("DiskEmulatorFile_1C14D9BC-3056-4fdf-9BE5-CEFC9C7EF074");tstring GetDiskName(const char* disk){ tstring __disk; if (NULL == disk) { tstring curDir; GetMainModuleDir(curDir); assert(curDir... 阅读全文

posted @ 2012-09-07 15:51 jeJee 阅读(581) 评论(0) 推荐(0)

【C/C++】一种同步目录的实现——No“删除整个目录再拷贝”

摘要: // 算法是:// 遍历 dstDir,将所有 srcDir 中不存在的文件删除;// 遍历 srcDir,若与 dstDir 目录中对应文件的修改日期不一致则替换该文件;// 忽略 excludeFile 文件里指示的目录和文件。struct IgnoreName{ bool isDir; tchar fileName[MAX_PATH];};bool GetIgnoreNames(const char* excludeFile, std::vector<IgnoreName>& ignoreNames){ bool result = true; igno... 阅读全文

posted @ 2012-09-07 15:28 jeJee 阅读(567) 评论(0) 推荐(0)

【python】计算文件md5值

摘要: import md5import sysdef sumfile(fobj): m = md5.new() while True: d = fobj.read(8096) if not d: break m.update(d) return m.hexdigest()def md5sum(fname): if fname == '-': ret = sumfile(sys.stdin) else: try: f = file(fname, '... 阅读全文

posted @ 2012-09-07 15:10 jeJee 阅读(294) 评论(0) 推荐(0)

【python】递归复制文件或者文件夹到指定目录

摘要: def CopyFileOrDir(src, targetDir): print src, targetDir baseName = os.path.basename(src) print baseName targetFileOrDirName = os.path.join(targetDir, baseName) print targetFileOrDirName if os.path.isfile(src): open(targetFileOrDirName, "wb").write(open(src, "rb").read()) ... 阅读全文

posted @ 2012-09-07 15:08 jeJee 阅读(429) 评论(0) 推荐(0)

【python】获取系统当前登录的用户名

摘要: import win32apiprint win32api.GetUserName() 阅读全文

posted @ 2012-09-07 15:04 jeJee 阅读(1255) 评论(0) 推荐(0)

【C/C++】生成64位随机数

摘要: google到的,直接上代码:mt64.hView Code /* A C-program for MT19937-64 (2004/9/29 version). Coded by Takuji Nishimura and Makoto Matsumoto. This is a 64-bit version of Mersenne Twister pseudorandom number generator. Before using, initialize the state by using init_genrand64(seed) or init_by_arr... 阅读全文

posted @ 2012-09-07 15:02 jeJee 阅读(1867) 评论(0) 推荐(0)

【C/C++】字符串编码转换【Windows版】

摘要: StrConv.hView Code #pragma once#include <string> #ifdef _UNICODE#ifndef tchar#define tchar wchar_t#endif#ifndef tstring#define tstring std::wstring#endif#else#ifndef tchar#define tchar char#endif#ifndef tstring#define tstring std::string#endif#endif // _UNICODE//////////////////////////////... 阅读全文

posted @ 2012-09-07 14:52 jeJee 阅读(629) 评论(0) 推荐(0)

查询域名对应IP地址

摘要: 命令:nslookup详细说明:http://baike.baidu.com/view/441751.htm 阅读全文

posted @ 2012-09-07 14:41 jeJee 阅读(242) 评论(0) 推荐(0)

导航