text = '中华'
print(type(text))#<class 'str'>
text1 = text.encode('gbk')
print(type(text1))#<class 'bytes'>
print(text1)#b'\xd6\xd0\xbb\xaa'
text2 = text1.decode('gbk')
print(type(text2))#<class 'str'>
print(text2)#中华

text4= text.encode('utf-8')
print(type(text4))#<class 'bytes'>
print(text4)#b'\xe4\xb8\xad\xe5\x8d\x8e'
text5 = text4.decode('utf-8')
print(type(text5))#<class 'str'>
print(text5)#中华

import requests

url="http://www.baidu.com"
response = requests.get(url)
content = response.text.encode('iso-8859-1').decode('utf-8')
#把网页源代码解码成Unicode编码,然后用utf-8编码
print(content)

from selenium import webdriver # 导入webdriver模块

chrome_obj = webdriver.Chrome() # 打开Google浏览器
chrome_obj.get("https://www.baidu.com") # 打开 网址
print(chrome_obj.title)

from selenium import webdriver # 导入webdriver模块

chrome_obj = webdriver.Chrome() # 打开Google浏览器

chrome_obj.get(r"C:\desktop\text.html") # 打开本地 html页面

吴裕雄 实战PYTHON编程(5)的更多相关文章

  1. 吴裕雄 实战PYTHON编程(10)

    import cv2 cv2.namedWindow("frame")cap = cv2.VideoCapture(0)while(cap.isOpened()): ret, im ...

  2. 吴裕雄 实战PYTHON编程(9)

    import cv2 cv2.namedWindow("ShowImage1")cv2.namedWindow("ShowImage2")image1 = cv ...

  3. 吴裕雄 实战PYTHON编程(8)

    import pandas as pd df = pd.DataFrame( {"林大明":[65,92,78,83,70], "陈聪明":[90,72,76, ...

  4. 吴裕雄 实战PYTHON编程(7)

    import os from win32com import client word = client.gencache.EnsureDispatch('Word.Application')word. ...

  5. 吴裕雄 实战PYTHON编程(6)

    import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['Simhei']plt.rcParams['axes.unicode ...

  6. 吴裕雄 实战PYTHON编程(4)

    import hashlib md5 = hashlib.md5()md5.update(b'Test String')print(md5.hexdigest()) import hashlib md ...

  7. 吴裕雄 实战python编程(3)

    import requests from bs4 import BeautifulSoup url = 'http://www.baidu.com'html = requests.get(url)sp ...

  8. 吴裕雄 实战python编程(2)

    from urllib.parse import urlparse url = 'http://www.pm25x.com/city/beijing.htm'o = urlparse(url)prin ...

  9. 吴裕雄 实战python编程(1)

    import sqlite3 conn = sqlite3.connect('E:\\test.sqlite') # 建立数据库联接cursor = conn.cursor() # 建立 cursor ...

随机推荐

  1. Microsoft Dynamics CRM 2011 中 SQL 语句总结

    一.查询用户和团队 插入的类型:OwnerIdType 可以为用户或团队: 1.团队: select top 1 ObjectTypeCode from metadataschema.entity w ...

  2. OpenWrt在没有Luci时刷机

    scp上传bin文件到root文件夹下. sysupgrade openwrt-ar71xx-generic-dragino2-squashfs-sysupgrade.bin 等待重启

  3. MySQL 查看编码 排序规则

    查看数据库的排序规则 mysql> show variables like 'collation%'; +----------------------+-------------------+ ...

  4. Linux操作系统中/sbin/init程序的执行过程

    当init启动后,它通过执行各种启动事务来继续引导进程(检查并监视文件系统,启动后台程序daemons,等等),直至完成用户所有操作环境的设置工作.这里主要涉及4个程序:init.getty(aget ...

  5. bzoj 3795: 魏总刷DP

    Description 魏总,也就是DP魏又开始刷DP了.一共有n道题,第i道题魏总原本需要u[i]秒的时间.不过,为了表达对这些水题的藐视,魏总决定先睡k秒再开始刷题.魏总并不清楚自己会睡多久,只知 ...

  6. spring boot学习(2) SpringBoot 项目属性配置

    第一节:项目内置属性 application.properties配置整个项目的,相当于以前的web.xml: 注意到上一节的访问HelloWorld时,项目路径也没有加:直接是http://loca ...

  7. java web 程序---jsp连接mysql数据库的实例基础+表格显示

    <%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="g ...

  8. 转载-JavaWeb学习总结

    JavaWeb学习总结(五十三)——Web应用中使用JavaMail发送邮件 孤傲苍狼 2015-01-12 23:51 阅读:13407 评论:20     JavaWeb学习总结(五十二)——使用 ...

  9. IE, Firefox下,checkbox的钩钩一旦勾上,画面再刷新,钩钩还是勾上的解决方案

    如题,IE, Firefox下,checkbox的钩钩一旦勾上,画面再刷新,钩钩还是勾上的解决方案 <input type="checkbox"  />加上属性auto ...

  10. windows,linux下SVN实现自动更新WEB目录

    通过SVN进行版本库管理,每次提交后,都要在SVN服务器更新最新上传的版本到WEB目录进行同步.操作比较烦琐,而且效率也低.使用SVN钩子脚本进行WEB目录同步,可很好的解决这方面的问题.由于测试机器 ...