Big Red

来自CloudWiki
112.38.217.45讨论2018年5月17日 (四) 03:11的版本 第一个网络爬虫
跳转至: 导航搜索

第2章 建立网络爬虫

第一个网络爬虫

数值类型:整型,浮点型,复数型。 字符串类型

import requests
r = requests.get("http://www.baidu.com")#打开一个网页
print(r.status_code) #返回状态
r.encoding = 'utf-8'
print(r.text) #观察返回的内容
  • 常量:其值不发生改变的数据对象
  • 变量:使用id()函数可以查看变量的内存地址

基本命令 例如:

print("Hello World!")
1.字符串

字符串是最常见的数据类型,一般用来存储类似“句子”的数据,并放在单引号或双引号中。 例如:

string1='Python Web Scrappy'
string2="by Santos"
string3=string1+""+string2
print(string3)