coursera-使用python访问网络数据-密歇根大学

课程总体比较简单,是python for everyone的系列课程之一,零基础的朋友也好上手。
课程简单随记笔记在此记录一下。
week2
正则表达式
‘^From’ 以’From’为开头
‘.’匹配任意字符
‘.*’任意字符任意次数
\S 非空格字符
+ 表示一次或者多次 eg.\S+ 至少一个非空格字符
re.search()返回是否匹配正则表达式
re.findall()提取所有符合的字符串,返回一个列表
[0-9] 匹配一个数字
[]一个字符
默认贪婪匹配,即返回最长的符合的字符串
?代表不进行贪婪匹配
()提取的起始和结束
[^ ]一个非空格字符,这里^表示非

Quick Guide
^ Matches the beginning of a line
$ Matches the end of the line
. Matches any character
\s Matches whitespace
\S Matches any non-whitespace character
* Repeats a character zero or more times
*? Repeats a character zero or more times
(non-greedy)
+ Repeats a character one or more times
+? Repeats a character one or more times
(non-greedy)
[aeiou] Matches a single character in the listed set
[^XYZ] Matches a single character not in the listed set
[a-z0-9] The set of characters can include a range
( Indicates where string extraction is to start
) Indicates where string extraction is to end

week3
Socket使客户端和服务器端能够进行通信
TCP端口号
python 建立socket连接:

import socket
mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com',80))

HTTP协议
URL :协议名、主机名、文件名
请求-响应周期:
请求新页面GET请求、连接服务器、响应返回页面
收到、取回、显示

mysock.send('G
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值