随笔分类 -  python

上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 48 下一页
摘要:输出 阅读全文
posted @ 2018-11-22 20:32 anobscureretreat 阅读(211) 评论(0) 推荐(0) 编辑
摘要:import re x=re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest') print(x) 阅读全文
posted @ 2018-11-22 20:29 anobscureretreat 阅读(1404) 评论(0) 推荐(0) 编辑
摘要:def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam... 阅读全文
posted @ 2018-11-22 20:27 anobscureretreat 阅读(201) 评论(0) 推荐(0) 编辑
摘要:输出 阅读全文
posted @ 2018-11-22 19:49 anobscureretreat 阅读(450) 评论(0) 推荐(0) 编辑
摘要:import os with os.scandir(r"C:\Users\macname\Desktop") as it: for entry in it: if entry.name.startswith('Auto') and entry.is_file(): print(entry.name) 阅读全文
posted @ 2018-11-22 19:43 anobscureretreat 阅读(377) 评论(0) 推荐(0) 编辑
摘要:import os with os.scandir(r"C:\Users\macname\Desktop") as it: for entry in it: if not entry.name.startswith('Auto') and entry.is_file(): print(entry.name) 阅读全文
posted @ 2018-11-22 19:39 anobscureretreat 阅读(298) 评论(0) 推荐(0) 编辑
摘要:打印所有以.txt为结尾的文件名称 阅读全文
posted @ 2018-11-22 17:41 anobscureretreat 阅读(404) 评论(0) 推荐(0) 编辑
摘要:输出 阅读全文
posted @ 2018-11-22 17:27 anobscureretreat 阅读(193) 评论(0) 推荐(0) 编辑
摘要:import json,time # save data to json file def store(data): with open('data.json', 'w') as fw: # 将字典转化为字符串 # json_str = json.dumps(data) # fw.write(json_str) # 上面... 阅读全文
posted @ 2018-11-22 00:34 anobscureretreat 阅读(232) 评论(0) 推荐(0) 编辑
摘要:提示说是解码错误 可以用下面的方法判断json文件是否为空 但是在非空情况下会报错!!! 已解决!!!https://www.cnblogs.com/sea-stream/p/10011699.html 阅读全文
posted @ 2018-11-22 00:25 anobscureretreat 阅读(1864) 评论(0) 推荐(0) 编辑
摘要:输出 阅读全文
posted @ 2018-11-21 23:48 anobscureretreat 阅读(571) 评论(0) 推荐(0) 编辑
摘要:输出 阅读全文
posted @ 2018-11-21 23:36 anobscureretreat 阅读(1368) 评论(0) 推荐(0) 编辑
摘要:输出 阅读全文
posted @ 2018-11-21 23:13 anobscureretreat 阅读(2110) 评论(0) 推荐(0) 编辑
摘要:from datetime import date a = date(2001,2,18) b = date(2001,2,28) print(b-a) 阅读全文
posted @ 2018-11-21 10:30 anobscureretreat 阅读(315) 评论(0) 推荐(0) 编辑
摘要:d1 = {'a': 100, 'b': 200} d2 = {'x': 300, 'y': 200} d = d1.copy() d.update(d2) print(d) 阅读全文
posted @ 2018-11-20 19:53 anobscureretreat 阅读(272) 评论(0) 推荐(0) 编辑
摘要:my_dict = {'data1':100,'data2':-54,'data3':247} print(sum(my_dict.values())) 阅读全文
posted @ 2018-11-20 10:06 anobscureretreat 阅读(5922) 评论(0) 推荐(0) 编辑
摘要:color_dict = {'red':'#FF0000', 'green':'#008000', 'black':'#000000', 'white':'#FFFFFF'} for key in sorted(color_dict): print("%s: %s" % (key, color_di... 阅读全文
posted @ 2018-11-20 10:02 anobscureretreat 阅读(166) 评论(0) 推荐(0) 编辑
摘要:myDict = {'a':1,'b':2,'c':3,'d':4} print(myDict) if 'a' in myDict: del myDict['a'] print(myDict) 阅读全文
posted @ 2018-11-19 20:46 anobscureretreat 阅读(197) 评论(0) 推荐(0) 编辑
摘要:def is_vowel(char): all_vowels = 'aeiou' return char in all_vowels print(is_vowel('c')) print(is_vowel('e')) 阅读全文
posted @ 2018-11-19 20:12 anobscureretreat 阅读(2948) 评论(0) 推荐(0) 编辑
摘要:# Python program to convert decimal number into binary, octal and hexadecimal number system # Change this line for a different result dec = 344 print("The decimal value of",dec,"is:") print(bin(d... 阅读全文
posted @ 2018-11-19 20:02 anobscureretreat 阅读(173) 评论(0) 推荐(0) 编辑

上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 48 下一页