摘要: abs(x) 返回一个数的绝对值。参数可以是普通的整数,长整数或者浮点数。如果参数是个复数,返回它的模。 all(iterable) 如果iterable的所有元素为真(或者iterable为空), 返回True。 any(iterable) 如果iterable的任一元素为真,返回True。如果i 阅读全文
posted @ 2017-01-11 17:54 Jarning_Gau 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 例如 将 转换为 只需 即可 eval(expression[, globals[, locals]]) 参数是Unicode或者Latin-1编码的字符串,全局变量和局部变量可选。如果有全局变量,globals必须是个字典。如果有局部变量,locals可以是任何映射类型对象。 可以用来将字符串st 阅读全文
posted @ 2016-04-22 20:24 Jarning_Gau 阅读(1462) 评论(0) 推荐(0) 编辑
摘要: 今天因为工作的缘故,需要用Python写一个能够完全分解文件名的小程序。 结果: 阅读全文
posted @ 2016-04-20 21:42 Jarning_Gau 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 以下代码在Ubuntu14.10下实现 阅读全文
posted @ 2016-04-10 20:28 Jarning_Gau 阅读(2038) 评论(0) 推荐(0) 编辑
摘要: 如果用命令 g++ -g -Wall main.cpp 编译以下代码 : 1 2 3 4 5 6 7 8 9 10 11 12 /* file : main.cpp */ #include <stdio.h> int main() { int a[5] = { 1, 2, 2, 5, 1 }; fo 阅读全文
posted @ 2016-04-10 20:08 Jarning_Gau 阅读(11479) 评论(0) 推荐(0) 编辑
摘要: 银行业务模拟是队列中非常经典的应用之一,各种版本的数据结构教材在队列这一章节援引这一应用。 本程序算法来源于《数据结构(C语言版)》(清华大学出版社 严蔚敏,吴伟民编著)第65页。 本程序在Ubuntu14.10平台上,利用g++编译通过。 阅读全文
posted @ 2016-04-06 19:36 Jarning_Gau 阅读(484) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://mysrc.sinaapp.com/view_note/?id=395 阅读全文
posted @ 2016-03-31 09:04 Jarning_Gau 阅读(309) 评论(0) 推荐(0) 编辑
摘要: os.sep 可以取代操作系统特定的路径分隔符。windows下为 '\\' os.name 字符串指示你正在使用的平台。比如对于Windows,它是'nt',而对于Linux/Unix用户,它是 'posix' os.getcwd() 函数得到当前工作目录,即当前Python脚本工作的目录路径 o 阅读全文
posted @ 2016-03-29 18:28 Jarning_Gau 阅读(718) 评论(0) 推荐(0) 编辑
摘要: import shutil with open('/path/to/file', 'r') as f: with open('/path/to/file.new', 'w') as g: for line in f.readlines(): if '/local/server' not in line: ... 阅读全文
posted @ 2016-03-29 16:26 Jarning_Gau 阅读(1412) 评论(0) 推荐(0) 编辑
摘要: from itertools import islice input_file = open(file_name) for line in islice(input_file, 1, None): do_readline() 原文地址:http://blog.csdn.net/vernice/art 阅读全文
posted @ 2016-03-29 15:38 Jarning_Gau 阅读(851) 评论(0) 推荐(0) 编辑