摘要: import datetime nowTime = datetime.datetime.now() print(nowTime) yesterday = nowTime + datetime.timedelta(days = -1) justNow = nowTime + datetime.time 阅读全文
posted @ 2020-07-14 17:07 南山散人 阅读(957) 评论(0) 推荐(0) 编辑
摘要: import random def lottery(): result = [] for i in range(0,6): red = random.randint(1, 33) result.append(red) blue = random.randint(1, 16) result.appen 阅读全文
posted @ 2020-07-10 15:27 南山散人 阅读(1182) 评论(0) 推荐(0) 编辑
摘要: #百度热搜# -*- coding:utf-8 -*- import requests from bs4 import BeautifulSoup url = "http://top.baidu.com/buzz?b=1&fr=topindex" header = { "user-agent": " 阅读全文
posted @ 2020-07-06 15:15 南山散人 阅读(222) 评论(0) 推荐(0) 编辑
摘要: CSS 选择器:BeautifulSoup4 例子: response = """<html><head><title>The Dormouse's story</title></head><body><p class="title" name="dromouse"><b>The Dormouse' 阅读全文
posted @ 2020-04-03 11:00 南山散人 阅读(547) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 def a_new_decorator(a_func): def wrapTheFunction(): print("I am doing some boring work before executing a_func()") a_func() print(" 阅读全文
posted @ 2020-03-27 15:29 南山散人 阅读(80) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 from functools import reduce def test_args(f_arg,*args): print("f_arg is", f_arg) for arg in args: print ("another arg through *arg 阅读全文
posted @ 2020-03-27 15:00 南山散人 阅读(126) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 -*- import requests from bs4 import BeautifulSoup import xlrd,xlwt urls = [ "https://maoyan.com/board/4?offset={}".format(i) for i 阅读全文
posted @ 2020-03-18 18:39 南山散人 阅读(444) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 -*- import requests from bs4 import BeautifulSoup import xlrd,xlwt urls = [ "https://maoyan.com/board/4?offset={}".format(i) for i 阅读全文
posted @ 2020-03-18 16:45 南山散人 阅读(502) 评论(0) 推荐(0) 编辑
摘要: 由于python官方源是在国外,在国内的我们由于某些原因在使用pip安装需要的包时,往往会比较慢甚至是失败,这时换源为豆瓣源后就可以很快的下载成功。 python3 -m pip install jieba -i https://pypi.douban.com/simple/ 阅读全文
posted @ 2020-03-12 17:50 南山散人 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 1.map() map()是python内置的高阶函数(一个函数可以作为参数传给另外一个函数,或者一个函数的返回值为另外一个函数【若返回值为该函数本身,则为递归】,满足其一则为高阶函数),它接收一个函数f和一个list,并通过把函数f依次作用在list的每个元素上,返回一个新的list。 # -*- 阅读全文
posted @ 2020-01-16 13:53 南山散人 阅读(171) 评论(0) 推荐(0) 编辑