python基础知识——基于python3.6
语法糖
# # -*- coding: utf-8 -*-
# #-------------
# #--------- 语法糖---------------
# #-----------------------------------
# def a(fun):
# print('aaaaaa')
# fun()
# print('bbbbb')
# return (
#
# )
# @a
# def fun():
# print('hello')#要注入的
正则match
# 搜索
#---------------------
# import re
# point = re.match('dd','www.nuaud.nadn')
# if point is not None:
# print(point.span())
# else:
# print('no')
# import re
用正则表达式搜索8位或11位手机号
------------------------------
#电话号码
#---------------------------
# point = re.search('^[0-9]{8}$|^[0-9]{11}$', '125667889999')
# if point is not None:
# print(point.span())
# else:
# print('no')
#------------------
用正则表达式查找日期
#查找日期
#-----------------------------
# 2017-03-05
# import re
# point = re.search('^[0-9]{4}-[0-1]{0,1}-[0-3]{0,1}-[0-9]{1}', '125667889999')
# if point is not None:
# print(point.span())
# else:
# print('no')
get方式
#get方式
#--------------------------
# import urllib.request
# f=urllib.request.urlopen("http://m.cnblogs.com/")
# s=f.read()
# print(s)
#------------
正则提取
#正则提取
# #--------------------------
# import re
# from urllib.request import urlopen
# f = urlopen("http://www.meishij.net/")
# s = f.read()
# s=s.decode('utf-8')
# mm = re.findall('<a href=\"(.*)\">(.*)</a>',str(s))
# print((mm))
# print((mm)[0][1])
爬虫爬一个网站
#爬招聘网站------------------------------
#---------------------------------
# import re
# from urllib.request import urlopen
# from urllib.request import Request
# headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
# url = "http://sou.zhaopin.com/jobs/searchresult.ashx?jl=%E5%8C%97%E4%BA%AC&kw=python&sm=0&p=1"
# req_timeout = 5#______________________________--------------添加模拟浏览器协议头
# req = Request(url=url,headers=headers)
# f = urlopen(req,None,req_timeout)
# s = f.read()
# s = s.decode('utf-8')
# mm = str(s)
用代码新建一个文件,并写入txt文档
#新建file 写入txt——————————————————
#————————————————
# f=open("file/test.txt",'w')
# f.write("First line 1.\n" )
# f.write("First line 2.\n" )
# f.write("First line 3.\n")
python基础知识——基于python3.6的更多相关文章
- python 基础知识(一)
python 基础知识(一) 一.python发展介绍 Python的创始人为Guido van Rossum.1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本 ...
- Python基础知识(五)
# -*- coding: utf-8 -*-# @Time : 2018-12-25 19:31# @Author : 三斤春药# @Email : zhou_wanchun@qq.com# @Fi ...
- Python 基础知识(一)
1.Python简介 1.1.Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打发时 ...
- python基础系列教程——Python3.x标准模块库目录
python基础系列教程——Python3.x标准模块库目录 文本 string:通用字符串操作 re:正则表达式操作 difflib:差异计算工具 textwrap:文本填充 unicodedata ...
- python基础知识部分练习大全
python基础知识部分练习大全 1.执行 Python 脚本的两种方式 答:1.>>python ../pyhton.py 2. >>python.py #必须在首行 ...
- python基础知识(一)
Python基础知识 计算基础知识 1.cpu 人类的大脑 运算和处理问题 2.内存 临时存储数据 断电就消失了 3.硬盘 永久存储数据 4.操作系统 调度硬件设备之间数据交互 python的应用和历 ...
- Python基础知识(五)------字典
Python基础知识(四)------字典 字典 一丶什么是字典 dict关键字 , 以 {} 表示, 以key:value形式保存数据 ,每个逗号分隔 键: 必须是可哈希,(不可变的数据类型 ...
- Python 入门之Python基础知识
Python 入门之Python基础知识 1.变量 (1)变量就是把程序运行的中间结果临时存在内存中,以便后续代码使用 (2)变量的作用: 昵称,就是代指内存中某个地址中的内容 a = 123 变量名 ...
- Python开发【第二篇】:Python基础知识
Python基础知识 一.初识基本数据类型 类型: int(整型) 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1,即-2147483648-2147483647 在64位 ...
随机推荐
- 第5章 不要让线程成为脱缰的野马(Keeping your Threads on Leash) ---干净的终止一个线程
干净的终止一个线程 我曾经在第2章产生一个后台线程,用以输出一张屏幕外的 bitmap 图.我们必须解决的一个最复杂的问题就是,如果用户企图结束程序,而这张bitmap 图尚未完成,怎么办?第2章的 ...
- 简单说明CGI是什么
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- 上传文件没有写权限Access to the path is denied
Access to the path is denied. asp.net程序目录放在系统盘,ntfs格式. 程序中对cfg.xml有写入操作. 运行的时候出现了这个问题. 在我自己的机器上没有问题 ...
- JS封装运动框架(另一种写法)
function animate(obj, json, interval, sp, fn) { clearInterval(obj.timer); //var k = 0; //var j = 0; ...
- Jquery+Ajax限制查询间隔
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Jquery20150305.a ...
- asp.net中kindeditor配置
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>KindEditor< ...
- 深入浅出 SpringMVC - 1
前言: 本篇笔记是LZ在之前学习 SpringMVC 框架时所的记录,分两篇分享,此篇为基础篇,包括 SpringMVC 环境在 Eclipse 中的搭建,SpringMVC 的 HelloWorld ...
- 继承“HibernateDaoSupport”后,报“The hierarchy of the type AccoutDaoImpl is inconsistent”的解决方案
解决办法: 今天写了一段很简单的代码,Eclipse竟然报错 import org.springframework.jdbc.core.support.JdbcDaoSupport; import c ...
- maven的java web项目启动找不到Spring ContextLoaderListener的解决办法
用maven搭建的java web项目,上传到git仓库后,当同事clone下来项目,部署到tomcat运行时,就报了如下错误,即启动web项目时,加载web.xml文件,找不到spring的监听器, ...
- python中sys.exit()和os._exit(0)退出程序
python中退出程序的两种方法,0为默认状态,可以为空,两者均会退出当前运行的程序,os._exit(0)中的0不能省略 sys.exit(0):可以捕获SystemExit异常,然后做相应的清理工 ...