【整理】python中去除数组List中重复的值,即数组去重
crifan 13年前 (2012-03-16) 9521浏览 2评论
参考代码: def unique(old_list): newList = [] for x in old_list: if x not in newList : newList.append(...
工作相关的技术文章
crifan 13年前 (2012-03-16) 9521浏览 2评论
参考代码: def unique(old_list): newList = [] for x in old_list: if x not in newList : newList.append(...
crifan 13年前 (2012-03-16) 5078浏览 1评论
关于如何替换,参考这里: http://www.cnpythoner.com/post/65.html 解释有两种: (1)用字符串本身的replace方法 a = 'hello word'; a....
crifan 13年前 (2012-03-16) 5839浏览 2评论
【Python中如何获得当前所执行的脚本的名字】 sys.argv[0]是传入的参数,通过解析,可以得到当前python脚本的文件名。 直接给出参考代码: # got script self's name # for : python hi-baid...
crifan 13年前 (2012-03-16) 5007浏览 0评论
参考代码: import os; cur_path = os.getcwd(); new_dir = cur_path + '\\' + 'dir0' + '\\dir1'; print "new dir exist=",os....
crifan 13年前 (2012-03-16) 2766浏览 0评论
参考这里: python学习笔记——字符串 摘录其整理的表格,供参考: 类型 方法 注解 填充 center(width[, fillchar]), ljust(width[, fillchar]), ...
crifan 13年前 (2012-03-16) 16581浏览 0评论
通过百分号%,加上括号来实现,直接上参考代码: int_val = 123; str_val = "hello"; formated_str = " Python sprintf test: digit=%d, stri...
crifan 13年前 (2012-03-16) 16487浏览 2评论
首先我们知道,python中字符包括两种,一个是普通的字符str,另一种是unicode字符。 我们实际的需求,很可能是不知道字符是什么编码的,即不知道是普通的str还是unicode,即使知道unicode,也不一定知道是什么格式存储的,即是u...
crifan 13年前 (2012-03-16) 3232浏览 0评论
isinstance函数的原型是: isinstance(object, classinfo) Return true if the object argument is an instance of the classinfo argumen...
crifan 13年前 (2012-03-16) 4621浏览 0评论
(1) 如何用for循环去枚举出一个字符串中所有的字母 Python基础篇 http://www.tsnc.edu.cn/default/tsnc_wgrj/doc/python/basic.htm#id2878558 已经介绍了,字...
crifan 13年前 (2012-03-16) 11051浏览 0评论
python中没有goto,好像也有其他模块模拟出来goto供有需要的人使用,但是很明显,goto破坏程序的逻辑,所以一般来说,也不推荐使用goto,能不用,最好不要用。 但是,很多时候,我们又有类似需求。 经过测试,自己写了个,类似goto的实现,...