摘要: #! python3 # mapIt.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip #如果命令输入了参数,就从命令里得到地名 if len(sys.argv) > 1: # Get add... 阅读全文
posted @ 2019-03-13 16:24 晨光曦微 阅读(347) 评论(0) 推荐(0)
摘要: import requests,re,json,time from requests.exceptions import RequestException headers={ 'User-Agent':'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' } def get_one_page(url): r=requests.g... 阅读全文
posted @ 2019-03-13 16:23 晨光曦微 阅读(237) 评论(0) 推荐(0)
摘要: #匹配电话,例如:415-555-4242 def isPhoneNumber(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-... 阅读全文
posted @ 2019-03-13 16:21 晨光曦微 阅读(506) 评论(0) 推荐(0)
摘要: import traceback try: raise Exception('这是一个错误信息') except: errFile=open('err.txt','w') errFile.write(traceback.format_exc()) errFile.close() print('错误信息已经写入err.txt文件中') 阅读全文
posted @ 2019-03-13 16:20 晨光曦微 阅读(209) 评论(0) 推荐(0)
摘要: import requests,bs4,os #利用 requests 模块下载页面 url='http://xkcd.com' os.makedirs('xkcd', exist_ok=True) #创建一个文件夹xkcd while not url.endswith('#'): res=requests.get(url) res.raise_for_status() #没... 阅读全文
posted @ 2019-03-13 16:19 晨光曦微 阅读(898) 评论(0) 推荐(0)
摘要: class Dog(): def __init__(self,name,age): self.name=name self.age=age def sit(self): print(self.name.title()+' 现在坐下了') def roll_over(self): print(self.name... 阅读全文
posted @ 2019-03-13 16:18 晨光曦微 阅读(268) 评论(0) 推荐(0)
摘要: def hello(): print('Howdy!') print('Howdy!!!') print('Hello there.') hello() 阅读全文
posted @ 2019-03-13 16:17 晨光曦微 阅读(206) 评论(0) 推荐(0)
摘要: import random heads = 0 for i in range(1, 1001): if random.randint(0, 1) == 1: heads = heads + 1 if i == 500: print('Halfway done!') print('Heads came up ' + str(heads) + ' ti... 阅读全文
posted @ 2019-03-13 16:15 晨光曦微 阅读(135) 评论(0) 推荐(0)
摘要: ##小程序,计算一个字符串中每个字符出现的次数+ import pprint message = 'It was a bright cold day in April, and the clocks were striking thirteen.' count = {} for character in message: count.setdefault(character, 0) ... 阅读全文
posted @ 2019-03-13 16:14 晨光曦微 阅读(686) 评论(0) 推荐(0)
摘要: ''' picnicItems 野餐用品清单 picnicItems sandwiches.................... 4apples........................ 12cups.......................... 4cookies........... 阅读全文
posted @ 2019-03-13 16:13 晨光曦微 阅读(231) 评论(0) 推荐(0)