摘要: #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 生活就是一种修行者 阅读(179) 评论(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 生活就是一种修行者 阅读(159) 评论(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 生活就是一种修行者 阅读(345) 评论(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 生活就是一种修行者 阅读(175) 评论(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 生活就是一种修行者 阅读(267) 评论(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 生活就是一种修行者 阅读(204) 评论(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 生活就是一种修行者 阅读(112) 评论(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:28 生活就是一种修行者 阅读(77) 评论(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 生活就是一种修行者 阅读(827) 评论(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 生活就是一种修行者 阅读(558) 评论(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 生活就是一种修行者 阅读(163) 评论(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 生活就是一种修行者 阅读(257) 评论(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 生活就是一种修行者 阅读(433) 评论(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 生活就是一种修行者 阅读(1815) 评论(0) 推荐(0) 编辑