摘要:1 #coding:utf-8 2 import urllib2 3 import os,sys 4 from BeautifulSoup import BeautifulSoup # For processing HTML 5 from bs4 import BeautifulSoup 6 class BookSave(): 7 ''' 8 dir:html文件保存目录 url:index.html目录 static_url:js、css所在目录的上级目录 9 distinguish:用来区分相同tag.name dis_k...
阅读全文
随笔分类 - python
摘要:python排序算法1、冒泡排序: 1 import math 2 def BubbleSort(list): 3 lengthOfList = len(list) 4 for i in range(0,lengthOfList-1): 5 for j in xrange(i+1,lengthOfList): 6 if list[i]>list[j]: 7 temp = list[i] 8 list[i] = list[j] 9 list[j]...
阅读全文
摘要:#2、已知a1=1,a2=2,an=a(n-1)+a(n-2)(n>=3),求数列{a1,a2,a3....an}的总和 1 import math 2 arr = [0]*100 3 num = 0 4 for i in range(0,100): 5 if i>=3: 6 arr[i]=arr[i-1] + arr[i-2] 7 num += arr[i] 8 else: 9 arr[i] = i + 110 num += arr[i]11 print num
阅读全文
摘要:#1、计算1000以内3与5的倍数的总和 1 import math 2 3 nums = 0 4 5 for i in range(0,1000): 6 7 if i%3 == 0 or i%5 == 0 : 8 9 if i != 0:10 11 nums = nums + i12 13 else:14 15 continue16 17 print numsView Code
阅读全文
浙公网安备 33010602011771号