摘要:
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
晨光曦微
阅读(509)
评论(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
晨光曦微
阅读(213)
评论(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
晨光曦微
阅读(899)
评论(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
晨光曦微
阅读(270)
评论(0)
推荐(0)
摘要:
def hello(): print('Howdy!') print('Howdy!!!') print('Hello there.') hello() 阅读全文
posted @ 2019-03-13 16:17
晨光曦微
阅读(208)
评论(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
晨光曦微
阅读(139)
评论(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
晨光曦微
阅读(691)
评论(0)
推荐(0)
摘要:
''' picnicItems 野餐用品清单 picnicItems sandwiches.................... 4apples........................ 12cups.......................... 4cookies........... 阅读全文
posted @ 2019-03-13 16:13
晨光曦微
阅读(236)
评论(0)
推荐(0)
摘要:
def boxPrint(symbol, width, height): if len(symbol) != 1: raise Exception('Symbol(符号) must be a single character string.') if width <= 2: raise Exception('Width must be greate... 阅读全文
posted @ 2019-03-13 16:12
晨光曦微
阅读(331)
评论(0)
推荐(0)

浙公网安备 33010602011771号