07 2018 档案

摘要:https://blog.csdn.net/lengxingxing_/article/details/56317838 阅读全文
posted @ 2018-07-04 19:18 生活就是一种修行者 阅读(111) 评论(0) 推荐(0)
摘要:数据分析需求: 每行内容需要生成以每行 首年月日为名称的文件, 文件内容写入|0|后的所有 行内容(也包括|0| 算法分析: Ø遍历每一行,每行取头14个字母 Ø 新建文件,文件名为首14个字母,然后把第15字符后的所有字 符拷贝到文件中 Ø 关闭文件 fp =open("e:\\data.log" 阅读全文
posted @ 2018-07-04 18:52 生活就是一种修行者 阅读(96) 评论(0) 推荐(0)
摘要:#题目:输入三个整数x,y,z,请把这三个数由小到大输出。 #程序分析:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。 x=4 y=2 z=9 if x>y: x,y=y,x if x>z 阅读全文
posted @ 2018-07-04 18:32 生活就是一种修行者 阅读(211) 评论(0) 推荐(0)
摘要:import time fileNo=1 backup_content="" line_count=0 fp = open("e:\\1.txt","r+") for line in fp: backup_content+=line line_count+=1 if line_count%10==0 阅读全文
posted @ 2018-07-04 18:32 生活就是一种修行者 阅读(156) 评论(0) 推荐(0)
摘要:练习:使用程序建立一个目录test,下面建立10个子目录,从1-10,每个目录下建立一个txt文件,文件名使用随机的整数数字,文件内容写入当前的目录路径和文件名 1 使用程序建立一个目录test,需要判断路径是否存在,如果不存在才新建, 2 test目录下面建立10个子目录,从1-10, 3 每个目 阅读全文
posted @ 2018-07-04 18:30 生活就是一种修行者 阅读(915) 评论(0) 推荐(0)
摘要:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少? #encoding=utf-8 result=[] for i in range(1,5): for j in range(1,5): for m in range(1,5): if i!=j and i!=m and 阅读全文
posted @ 2018-07-04 18:30 生活就是一种修行者 阅读(209) 评论(0) 推荐(0)
摘要:import os file_names=[] for root, dirs, files in os.walk("e:\\test2",topdown=False) : for name in files: file_names.append(os.path.splitext(name)[0]) 阅读全文
posted @ 2018-07-04 18:29 生活就是一种修行者 阅读(140) 评论(0) 推荐(0)
摘要:'''import os file_num=0 for root, dirs, files in os.walk("e:\\asd",topdown=False) : for name in files : if ".txt" == name[-4:]: #方法2if ".txt" in name: 阅读全文
posted @ 2018-07-04 18:28 生活就是一种修行者 阅读(123) 评论(0) 推荐(0)
摘要:1.基本的读取配置文件 -read(filename) 直接读取文件内容 (windows 下的 .conf 及 .ini 文件等)-sections() 得到所有的section,并以列表的形式返回-options(section) 得到该section的所有option-items(sectio 阅读全文
posted @ 2018-07-04 10:02 生活就是一种修行者 阅读(1420) 评论(0) 推荐(0)
摘要:#encoding=utf-8 import os dir_num=0 file_num=0 for root, dirs, files in os.walk("e:\\test2",topdown=False) : #print u"当前目录:",root #打印目录绝对路径 for name i 阅读全文
posted @ 2018-07-02 19:44 生活就是一种修行者 阅读(181) 评论(0) 推荐(0)
摘要:#encoding=utf-8 import os for root, dirs, files in os.walk("e:\\test2",topdown=False) : print u"当前目录:",root #打印目录绝对路径 for name in files : print u'文件名: 阅读全文
posted @ 2018-07-02 19:37 生活就是一种修行者 阅读(160) 评论(0) 推荐(0)
摘要:#encoding=utf-8 import os for root, dirs, files in os.walk("e:\\test2",topdown=False) : #print u"当前目录:",root #打印目录绝对路径 for name in files : #print u'文件 阅读全文
posted @ 2018-07-02 19:37 生活就是一种修行者 阅读(360) 评论(0) 推荐(0)
摘要:例如2+22+222+2222+22222(此时共有5个数相加),几个数相加和a的值由键盘控制。 a=int(raw_input("input a value:")) times=int(raw_input("input count times:")) print u"总和为:",eval("+". 阅读全文
posted @ 2018-07-02 19:34 生活就是一种修行者 阅读(189) 评论(0) 推荐(0)
摘要:s="123 abc !@# ^&*" digit_num=0 letter_num=0 space_num=0 other_num=0 for i in s: if i.isalpha(): letter_num+=1 elif i.isdigit(): digit_num+=1 elif i.i 阅读全文
posted @ 2018-07-02 19:31 生活就是一种修行者 阅读(280) 评论(0) 推荐(0)
摘要:#encoding=utf-8 import sys sum=0 for i in sys.argv[1:]: try: number=float(i) except: continue sum+=number print sum #encoding=utf-8 import sys letter_ 阅读全文
posted @ 2018-07-02 19:30 生活就是一种修行者 阅读(207) 评论(0) 推荐(0)
摘要:import sys letter_count=0 for i in sys.argv[1:]: for j in i: # if j.isalpha(): if (j>="a" and j<="z") or (j>="A" and j<="Z"): letter_count+=1 print le 阅读全文
posted @ 2018-07-02 19:29 生活就是一种修行者 阅读(113) 评论(0) 推荐(0)
摘要:#encoding=utf-8 week_num=raw_input("input:") if week_num.lower()=="m": print "today is monday" elif week_num.lower()=="w": print "today is wednesday" 阅读全文
posted @ 2018-07-02 19:25 生活就是一种修行者 阅读(846) 评论(0) 推荐(0)
摘要:X = [[12,7,3], [4 ,5,6], [7 ,8,9]] Y = [[5,8,1], [6,7,3], [4,5,9]] #encoding=utf-8 z=[ [0,0,0], [0,0,0], [0,0,0] ] x = [[12,7,3], [4 ,5,6], [7 ,8,9]] 阅读全文
posted @ 2018-07-02 19:25 生活就是一种修行者 阅读(589) 评论(0) 推荐(0)
摘要:程序分析:学会分解出每一位数。 number= raw_input("please input a number length is less than 5:") print len(number) for i in str(numbe)[::-1]: print i 阅读全文
posted @ 2018-07-02 19:23 生活就是一种修行者 阅读(172) 评论(0) 推荐(0)
摘要:a=[1,2,3,4,5,6,7] m=4 last_m_numbers=a[-m:] print last_m_numbers front_numbers=a[:-m] print front_numbers print last_m_numbers+front_numbers 阅读全文
posted @ 2018-07-02 19:22 生活就是一种修行者 阅读(284) 评论(0) 推荐(0)
摘要:#coding=utf-8 a= [] while 1: try: user_input = raw_input('please input a number:') if user_input.strip() =='over': break else: a.append(int(user_input 阅读全文
posted @ 2018-07-02 19:19 生活就是一种修行者 阅读(442) 评论(0) 推荐(0)
摘要:#encoding=utf-8 a=[ [1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16] ] #所有元素的和 sum=0 for i in a: for j in i: sum+=j print sum #一条对角线 sum_diagonal=0 f 阅读全文
posted @ 2018-07-02 19:12 生活就是一种修行者 阅读(1894) 评论(0) 推荐(0)