上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 38 下一页
摘要: Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1.0'如果写int("1.0")就会错误,因为python假设需要进行int转型的... 阅读全文
posted @ 2013-12-09 09:12 前行者2011 阅读(199) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8'''对应列的值相加'''a=['8533873.000000', '4922178.500000', '7.419005', '63.000282', '59']b=['8422450.000000', '4791319.500000', '9.877247', '63.... 阅读全文
posted @ 2013-12-05 19:09 前行者2011 阅读(175) 评论(0) 推荐(0) 编辑
摘要: subprocess.Popen用来创建子进程。1)Popen启动新的进程与父进程并行执行,默认父进程不等待新进程结束。defTestPopen():importsubprocessp=subprocess.Popen("dir",shell=True)foriinrange(250):print(... 阅读全文
posted @ 2013-12-04 18:20 前行者2011 阅读(101) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8import fileinputdef main(): lineno=0 for line in fileinput.input(r'G:\\subprocess.log'): lineno=fileinput.filelineno() re... 阅读全文
posted @ 2013-12-04 18:19 前行者2011 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 生成动态随机密码:import random,string'''length -- 指定密码的长度chars -- 指定密码有字母、数字、下划线及@、#组成times -- 指定一次生成的密码个数'''chars = string.lowercase+string.uppercase+''.jo... 阅读全文
posted @ 2013-12-04 17:23 前行者2011 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 在熟悉了Qt的QProcess以后,再回头来看python的subprocess总算不觉得像以前那么恐怖了。和QProcess一样,subprocess的目标是启动一个新的进程并与之进行通讯。subprocess.Popen这个模块主要就提供一个类Popen:class subprocess.Pop... 阅读全文
posted @ 2013-12-04 17:13 前行者2011 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 去除文件中的重复元素后写入文件#coding:utf-8import fileinputimport re#只包含单行的数据文件f=open(r'D:\snowDocument\excludes.txt','w')#匹配行内容中包含 '-'的字符p2=re.compile('-')def main(... 阅读全文
posted @ 2013-12-03 11:21 前行者2011 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 描述: 给你一个正整数列表 L, 如 L=[2,8,3,50], 判断列表内所有数字乘积的最后一个非零数字的奇偶性,奇数输出1,偶数输出0. 如样例输出应为0#coding:utf-8L=[2,8,3,50]product=1for i in L: product *=idef main():... 阅读全文
posted @ 2013-12-02 18:04 前行者2011 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8'''获取 数字n由2组成的个数,如8=2*2*2,由3个2组成。也可以改变因子元素2,获取相应的因子个数'''m=0def main(n): global m if n%2==0: m+=1 main(n/2) if ... 阅读全文
posted @ 2013-12-02 16:57 前行者2011 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 这是网上的一道题目,内容如下:描述: 给你一个正整数列表 L, 如 L=[2,8,3,50], 输出L内所有数字的乘积末尾0的个数,如样例L的结果为2.(提示:不要直接相乘,数字很多,可能溢出)#coding:utf-8'''思路:由于2x5=10,分别输出由2和5组成的列表元素乘积,得到2、5的个... 阅读全文
posted @ 2013-12-02 16:46 前行者2011 阅读(206) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 38 下一页