1689 lines
101 KiB
HTML
1689 lines
101 KiB
HTML
|
||
<!DOCTYPE HTML>
|
||
<html lang="zh-hans" >
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||
<title>2-9 python3小白课:字符串进阶 · python3小白课笔记</title>
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||
<meta name="description" content="">
|
||
<meta name="generator" content="GitBook 3.2.3">
|
||
<meta name="author" content="雪山凌狐">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/style.css">
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-material-light.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-auto-scroll-table/website.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-ad/plugin.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-image-captions/image-captions.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../css/website.css">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<meta name="HandheldFriendly" content="true"/>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||
|
||
|
||
<link rel="next" href="2-10 python3小白课:赋值运算符.html" />
|
||
|
||
|
||
<link rel="prev" href="2-8 python3小白课:字节串.html" />
|
||
|
||
|
||
|
||
<link rel="shortcut icon" href='../assets/favicon.ico' type="image/x-icon">
|
||
|
||
|
||
<link rel="bookmark" href='../assets/favicon.ico' type="image/x-icon">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body>
|
||
|
||
<div class="book">
|
||
<div class="book-summary">
|
||
|
||
|
||
<div id="book-search-input" role="search">
|
||
<input type="text" placeholder="输入并搜索" />
|
||
</div>
|
||
|
||
|
||
<nav role="navigation">
|
||
|
||
|
||
|
||
<ul class="summary">
|
||
|
||
|
||
|
||
|
||
<li>
|
||
<a href="http://fox-9.com" target="_blank" class="custom-link">雪山凌狐教程</a>
|
||
</li>
|
||
|
||
|
||
|
||
|
||
<li class="divider"></li>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<li class="chapter " data-level="1.1" data-path="../">
|
||
|
||
<a href="../">
|
||
|
||
|
||
Python3小白课 介绍
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.2" data-path="../Catalog.html">
|
||
|
||
<a href="../Catalog.html">
|
||
|
||
|
||
课程目录
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3" data-path="../chapter1/">
|
||
|
||
<a href="../chapter1/">
|
||
|
||
|
||
一、Python初识
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.3.1" data-path="../chapter1/1-1 python3小白课:python语言简介.html">
|
||
|
||
<a href="../chapter1/1-1 python3小白课:python语言简介.html">
|
||
|
||
|
||
1-1 python3小白课:python语言简介
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.2" data-path="../chapter1/1-2 python3小白课:python下载.html">
|
||
|
||
<a href="../chapter1/1-2 python3小白课:python下载.html">
|
||
|
||
|
||
1-2 python3小白课:python下载
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.3" data-path="../chapter1/1-3 python3小白课:python安装.html">
|
||
|
||
<a href="../chapter1/1-3 python3小白课:python安装.html">
|
||
|
||
|
||
1-3 python3小白课:python安装
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.4" data-path="../chapter1/1-4 python3小白课:我的第一个python脚本.html">
|
||
|
||
<a href="../chapter1/1-4 python3小白课:我的第一个python脚本.html">
|
||
|
||
|
||
1-4 python3小白课:我的第一个python脚本
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.5" data-path="../chapter1/1-5 python3小白课:如何运行py文件.html">
|
||
|
||
<a href="../chapter1/1-5 python3小白课:如何运行py文件.html">
|
||
|
||
|
||
1-5 python3小白课:如何运行py文件
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.6" data-path="../chapter1/1-6 python3小白课:使用python IDLE.html">
|
||
|
||
<a href="../chapter1/1-6 python3小白课:使用python IDLE.html">
|
||
|
||
|
||
1-6 python3小白课:使用python IDLE
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.3.7" data-path="../chapter1/1-7 python3小白课:使用python shell.html">
|
||
|
||
<a href="../chapter1/1-7 python3小白课:使用python shell.html">
|
||
|
||
|
||
1-7 python3小白课:使用python shell
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4" data-path="./">
|
||
|
||
<a href="./">
|
||
|
||
|
||
二、变量、简单类型和运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.4.1" data-path="2-1 python3小白课:啥是变量.html">
|
||
|
||
<a href="2-1 python3小白课:啥是变量.html">
|
||
|
||
|
||
2-1 python3小白课:啥是变量
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.2" data-path="2-2 python3小白课:定义常量.html">
|
||
|
||
<a href="2-2 python3小白课:定义常量.html">
|
||
|
||
|
||
2-2 python3小白课:定义常量
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.3" data-path="2-3 python3小白课:注释让你事半功倍.html">
|
||
|
||
<a href="2-3 python3小白课:注释让你事半功倍.html">
|
||
|
||
|
||
2-3 python3小白课:注释让你事半功倍
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.4" data-path="2-4 python3小白课:数值类型之整型.html">
|
||
|
||
<a href="2-4 python3小白课:数值类型之整型.html">
|
||
|
||
|
||
2-4 python3小白课:数值类型之整型
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.5" data-path="2-5 python3小白课:数值类型之浮点型.html">
|
||
|
||
<a href="2-5 python3小白课:数值类型之浮点型.html">
|
||
|
||
|
||
2-5 python3小白课:数值类型之浮点型
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.6" data-path="2-6 python3小白课:数值类型之复数.html">
|
||
|
||
<a href="2-6 python3小白课:数值类型之复数.html">
|
||
|
||
|
||
2-6 python3小白课:数值类型之复数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.7" data-path="2-7 python3小白课:字符串入门.html">
|
||
|
||
<a href="2-7 python3小白课:字符串入门.html">
|
||
|
||
|
||
2-7 python3小白课:字符串入门
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.8" data-path="2-8 python3小白课:字节串.html">
|
||
|
||
<a href="2-8 python3小白课:字节串.html">
|
||
|
||
|
||
2-8 python3小白课:字节串
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter active" data-level="1.4.9" data-path="2-9 python3小白课:字符串进阶.html">
|
||
|
||
<a href="2-9 python3小白课:字符串进阶.html">
|
||
|
||
|
||
2-9 python3小白课:字符串进阶
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.10" data-path="2-10 python3小白课:赋值运算符.html">
|
||
|
||
<a href="2-10 python3小白课:赋值运算符.html">
|
||
|
||
|
||
2-10 python3小白课:赋值运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.11" data-path="2-11 python3小白课:算术运算符.html">
|
||
|
||
<a href="2-11 python3小白课:算术运算符.html">
|
||
|
||
|
||
2-11 python3小白课:算术运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.12" data-path="2-12 python3小白课:索引运算符.html">
|
||
|
||
<a href="2-12 python3小白课:索引运算符.html">
|
||
|
||
|
||
2-12 python3小白课:索引运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.13" data-path="2-13 python3小白课:比较运算符.html">
|
||
|
||
<a href="2-13 python3小白课:比较运算符.html">
|
||
|
||
|
||
2-13 python3小白课:比较运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.14" data-path="2-14 python3小白课:身份运算符.html">
|
||
|
||
<a href="2-14 python3小白课:身份运算符.html">
|
||
|
||
|
||
2-14 python3小白课:身份运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.15" data-path="2-15 python3小白课:逻辑运算符.html">
|
||
|
||
<a href="2-15 python3小白课:逻辑运算符.html">
|
||
|
||
|
||
2-15 python3小白课:逻辑运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.16" data-path="2-16 python3小白课:位运算符.html">
|
||
|
||
<a href="2-16 python3小白课:位运算符.html">
|
||
|
||
|
||
2-16 python3小白课:位运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.17" data-path="2-17 python3小白课:赋值运算符扩展.html">
|
||
|
||
<a href="2-17 python3小白课:赋值运算符扩展.html">
|
||
|
||
|
||
2-17 python3小白课:赋值运算符扩展
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.18" data-path="2-18 python3小白课:三目运算符.html">
|
||
|
||
<a href="2-18 python3小白课:三目运算符.html">
|
||
|
||
|
||
2-18 python3小白课:三目运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.19" data-path="2-19 python3小白课:成员运算符.html">
|
||
|
||
<a href="2-19 python3小白课:成员运算符.html">
|
||
|
||
|
||
2-19 python3小白课:成员运算符
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.4.20" data-path="2-20 python3小白课:运算符优先级.html">
|
||
|
||
<a href="2-20 python3小白课:运算符优先级.html">
|
||
|
||
|
||
2-20 python3小白课:运算符优先级
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5" data-path="../chapter3/">
|
||
|
||
<a href="../chapter3/">
|
||
|
||
|
||
三、列表、元组和字典
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.5.1" data-path="../chapter3/3-1 python3小白课:列表和元组的区别.html">
|
||
|
||
<a href="../chapter3/3-1 python3小白课:列表和元组的区别.html">
|
||
|
||
|
||
3-1 python3小白课:列表和元组的区别
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5.2" data-path="../chapter3/3-2 python3小白课:列表元组入门.html">
|
||
|
||
<a href="../chapter3/3-2 python3小白课:列表元组入门.html">
|
||
|
||
|
||
3-2 python3小白课:列表元组入门
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5.3" data-path="../chapter3/3-3 python3小白课:深入列表.html">
|
||
|
||
<a href="../chapter3/3-3 python3小白课:深入列表.html">
|
||
|
||
|
||
3-3 python3小白课:深入列表
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5.4" data-path="../chapter3/3-4 python3小白课:字典初识.html">
|
||
|
||
<a href="../chapter3/3-4 python3小白课:字典初识.html">
|
||
|
||
|
||
3-4 python3小白课:字典初识
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5.5" data-path="../chapter3/3-5 python3小白课:字典操作基础.html">
|
||
|
||
<a href="../chapter3/3-5 python3小白课:字典操作基础.html">
|
||
|
||
|
||
3-5 python3小白课:字典操作基础
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.5.6" data-path="../chapter3/3-6 python3小白课:字典的常用方法.html">
|
||
|
||
<a href="../chapter3/3-6 python3小白课:字典的常用方法.html">
|
||
|
||
|
||
3-6 python3小白课:字典的常用方法
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.6" data-path="../chapter4/">
|
||
|
||
<a href="../chapter4/">
|
||
|
||
|
||
四、流程控制
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.6.1" data-path="../chapter4/4-1 python3小白课:if分支结构.html">
|
||
|
||
<a href="../chapter4/4-1 python3小白课:if分支结构.html">
|
||
|
||
|
||
4-1 python3小白课:if分支结构
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.6.2" data-path="../chapter4/4-2 python3小白课:while循环结构.html">
|
||
|
||
<a href="../chapter4/4-2 python3小白课:while循环结构.html">
|
||
|
||
|
||
4-2 python3小白课:while循环结构
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.6.3" data-path="../chapter4/4-3 python3小白课:for-in循环结构.html">
|
||
|
||
<a href="../chapter4/4-3 python3小白课:for-in循环结构.html">
|
||
|
||
|
||
4-3 python3小白课:for-in循环结构
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.6.4" data-path="../chapter4/4-4 python3小白课:for表达式.html">
|
||
|
||
<a href="../chapter4/4-4 python3小白课:for表达式.html">
|
||
|
||
|
||
4-4 python3小白课:for表达式
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7" data-path="../chapter5/">
|
||
|
||
<a href="../chapter5/">
|
||
|
||
|
||
五、自定义函数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.7.1" data-path="../chapter5/5-1 python3小白课:函数是什么.html">
|
||
|
||
<a href="../chapter5/5-1 python3小白课:函数是什么.html">
|
||
|
||
|
||
5-1 python3小白课:函数是什么
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.2" data-path="../chapter5/5-2 python3小白课:函数入门.html">
|
||
|
||
<a href="../chapter5/5-2 python3小白课:函数入门.html">
|
||
|
||
|
||
5-2 python3小白课:函数入门
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.3" data-path="../chapter5/5-3 python3小白课:递归函数.html">
|
||
|
||
<a href="../chapter5/5-3 python3小白课:递归函数.html">
|
||
|
||
|
||
5-3 python3小白课:递归函数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.4" data-path="../chapter5/5-4 python3小白课:关键字参数.html">
|
||
|
||
<a href="../chapter5/5-4 python3小白课:关键字参数.html">
|
||
|
||
|
||
5-4 python3小白课:关键字参数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.5" data-path="../chapter5/5-5 python3小白课:参数默认值.html">
|
||
|
||
<a href="../chapter5/5-5 python3小白课:参数默认值.html">
|
||
|
||
|
||
5-5 python3小白课:参数默认值
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.6" data-path="../chapter5/5-6 python3小白课:参数收集.html">
|
||
|
||
<a href="../chapter5/5-6 python3小白课:参数收集.html">
|
||
|
||
|
||
5-6 python3小白课:参数收集
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.7" data-path="../chapter5/5-7 python3小白课:变量作用域.html">
|
||
|
||
<a href="../chapter5/5-7 python3小白课:变量作用域.html">
|
||
|
||
|
||
5-7 python3小白课:变量作用域
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.7.8" data-path="../chapter5/5-8 python3小白课:局部函数.html">
|
||
|
||
<a href="../chapter5/5-8 python3小白课:局部函数.html">
|
||
|
||
|
||
5-8 python3小白课:局部函数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8" data-path="../chapter6/">
|
||
|
||
<a href="../chapter6/">
|
||
|
||
|
||
六、模块和包
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.8.1" data-path="../chapter6/6-1 python3小白课:模块的导入.html">
|
||
|
||
<a href="../chapter6/6-1 python3小白课:模块的导入.html">
|
||
|
||
|
||
6-1 python3小白课:模块的导入
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.2" data-path="../chapter6/6-2 python3小白课:自己写模块.html">
|
||
|
||
<a href="../chapter6/6-2 python3小白课:自己写模块.html">
|
||
|
||
|
||
6-2 python3小白课:自己写模块
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.3" data-path="../chapter6/6-3 python3小白课:导入模块详解.html">
|
||
|
||
<a href="../chapter6/6-3 python3小白课:导入模块详解.html">
|
||
|
||
|
||
6-3 python3小白课:导入模块详解
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.4" data-path="../chapter6/6-4 python3小白课:包是什么.html">
|
||
|
||
<a href="../chapter6/6-4 python3小白课:包是什么.html">
|
||
|
||
|
||
6-4 python3小白课:包是什么
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.5" data-path="../chapter6/6-5 python3小白课:定义包.html">
|
||
|
||
<a href="../chapter6/6-5 python3小白课:定义包.html">
|
||
|
||
|
||
6-5 python3小白课:定义包
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.6" data-path="../chapter6/6-6 python3小白课:包成员导入.html">
|
||
|
||
<a href="../chapter6/6-6 python3小白课:包成员导入.html">
|
||
|
||
|
||
6-6 python3小白课:包成员导入
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.7" data-path="../chapter6/6-7 python3小白课:模块内容查看.html">
|
||
|
||
<a href="../chapter6/6-7 python3小白课:模块内容查看.html">
|
||
|
||
|
||
6-7 python3小白课:模块内容查看
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.8" data-path="../chapter6/6-8 python3小白课:解锁你心仪的三方包.html">
|
||
|
||
<a href="../chapter6/6-8 python3小白课:解锁你心仪的三方包.html">
|
||
|
||
|
||
6-8 python3小白课:解锁你心仪的三方包
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.9" data-path="../chapter6/6-9 python3小白课:虚拟环境介绍和安装.html">
|
||
|
||
<a href="../chapter6/6-9 python3小白课:虚拟环境介绍和安装.html">
|
||
|
||
|
||
6-9 python3小白课:虚拟环境介绍和安装
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.8.10" data-path="../chapter6/6-10 python3小白课:虚拟环境使用.html">
|
||
|
||
<a href="../chapter6/6-10 python3小白课:虚拟环境使用.html">
|
||
|
||
|
||
6-10 python3小白课:虚拟环境使用
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9" data-path="../chapter7/">
|
||
|
||
<a href="../chapter7/">
|
||
|
||
|
||
七、类和对象
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.9.1" data-path="../chapter7/7-1 python3小白课:一节课搞懂面向对象.html">
|
||
|
||
<a href="../chapter7/7-1 python3小白课:一节课搞懂面向对象.html">
|
||
|
||
|
||
7-1 python3小白课:一节课搞懂面向对象
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.2" data-path="../chapter7/7-2 python3小白课:定义类和实例化对象.html">
|
||
|
||
<a href="../chapter7/7-2 python3小白课:定义类和实例化对象.html">
|
||
|
||
|
||
7-2 python3小白课:定义类和实例化对象
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.3" data-path="../chapter7/7-3 python3小白课:了解实例方法.html">
|
||
|
||
<a href="../chapter7/7-3 python3小白课:了解实例方法.html">
|
||
|
||
|
||
7-3 python3小白课:了解实例方法
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.4" data-path="../chapter7/7-4 python3小白课:用property函数定义属性.html">
|
||
|
||
<a href="../chapter7/7-4 python3小白课:用property函数定义属性.html">
|
||
|
||
|
||
7-4 python3小白课:用property函数定义属性
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.5" data-path="../chapter7/7-5 python3小白课:封装和隐藏.html">
|
||
|
||
<a href="../chapter7/7-5 python3小白课:封装和隐藏.html">
|
||
|
||
|
||
7-5 python3小白课:封装和隐藏
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.6" data-path="../chapter7/7-6 python3小白课:类的继承和多继承.html">
|
||
|
||
<a href="../chapter7/7-6 python3小白课:类的继承和多继承.html">
|
||
|
||
|
||
7-6 python3小白课:类的继承和多继承
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.7" data-path="../chapter7/7-7 python3小白课:重写父类方法和使用super函数.html">
|
||
|
||
<a href="../chapter7/7-7 python3小白课:重写父类方法和使用super函数.html">
|
||
|
||
|
||
7-7 python3小白课:重写父类方法和使用super函数
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.8" data-path="../chapter7/7-8 python3小白课:类的多态性.html">
|
||
|
||
<a href="../chapter7/7-8 python3小白课:类的多态性.html">
|
||
|
||
|
||
7-8 python3小白课:类的多态性
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.9.9" data-path="../chapter7/7-9 python3小白课:可以被枚举的类.html">
|
||
|
||
<a href="../chapter7/7-9 python3小白课:可以被枚举的类.html">
|
||
|
||
|
||
7-9 python3小白课:可以被枚举的类
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10" data-path="../chapter8/">
|
||
|
||
<a href="../chapter8/">
|
||
|
||
|
||
八、异常处理机制
|
||
|
||
</a>
|
||
|
||
|
||
|
||
<ul class="articles">
|
||
|
||
|
||
<li class="chapter " data-level="1.10.1" data-path="../chapter8/8-1 python3小白课:最基本的异常处理.html">
|
||
|
||
<a href="../chapter8/8-1 python3小白课:最基本的异常处理.html">
|
||
|
||
|
||
8-1 python3小白课:最基本的异常处理
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10.2" data-path="../chapter8/8-2 python3小白课:多异常捕获.html">
|
||
|
||
<a href="../chapter8/8-2 python3小白课:多异常捕获.html">
|
||
|
||
|
||
8-2 python3小白课:多异常捕获
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10.3" data-path="../chapter8/8-3 python3小白课:查看详细异常信息.html">
|
||
|
||
<a href="../chapter8/8-3 python3小白课:查看详细异常信息.html">
|
||
|
||
|
||
8-3 python3小白课:查看详细异常信息
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10.4" data-path="../chapter8/8-4 python3小白课:异常机制中的else块.html">
|
||
|
||
<a href="../chapter8/8-4 python3小白课:异常机制中的else块.html">
|
||
|
||
|
||
8-4 python3小白课:异常机制中的else块
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10.5" data-path="../chapter8/8-5 python3小白课:finally块回收资源.html">
|
||
|
||
<a href="../chapter8/8-5 python3小白课:finally块回收资源.html">
|
||
|
||
|
||
8-5 python3小白课:finally块回收资源
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.10.6" data-path="../chapter8/8-6 python3小白课:自己引发异常.html">
|
||
|
||
<a href="../chapter8/8-6 python3小白课:自己引发异常.html">
|
||
|
||
|
||
8-6 python3小白课:自己引发异常
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
</li>
|
||
|
||
<li class="chapter " data-level="1.11" data-path="../Summary.html">
|
||
|
||
<a href="../Summary.html">
|
||
|
||
|
||
课程总结
|
||
|
||
</a>
|
||
|
||
|
||
|
||
</li>
|
||
|
||
|
||
|
||
|
||
<li class="divider"></li>
|
||
|
||
<li>
|
||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||
本书使用 GitBook 发布
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
|
||
|
||
</nav>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="book-body">
|
||
|
||
<div class="body-inner">
|
||
|
||
|
||
|
||
<div class="book-header" role="navigation">
|
||
|
||
|
||
<!-- Title -->
|
||
<h1>
|
||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||
<a href=".." >2-9 python3小白课:字符串进阶</a>
|
||
</h1>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<div class="page-wrapper" tabindex="-1" role="main">
|
||
<div class="page-inner">
|
||
|
||
<div id="book-search-results">
|
||
<div class="search-noresults">
|
||
|
||
<section class="normal markdown-section">
|
||
|
||
<html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon fa fa-hand-o-right"></span><a href="#python3小白课:字符串进阶"><b></b>python3小白课:字符串进阶</a></li><ul><ul><li><span class="title-icon fa fa-hand-o-right"></span><a href="#转义字符"><b></b>转义字符</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#格式化字符串"><b></b>格式化字符串</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#format函数"><b></b>format函数</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#f-string"><b></b>f-string</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#字符串索引及相关方法"><b></b>字符串索引及相关方法</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#字符串str类型自带的一些内置方法"><b></b>字符串str类型自带的一些内置方法</a></li><li><span class="title-icon fa fa-hand-o-right"></span><a href="#单词释义"><b></b>单词释义</a></li></ul></ul></ul></div><h1 id="python3小白课:字符串进阶"><a name="python3小白课:字符串进阶" class="anchor-navigation-ex-anchor" href="#python3小白课:字符串进阶"><i class="fa fa-link" aria-hidden="true"></i></a>python3小白课:字符串进阶</h1>
|
||
<p>之前我们学习了python字符串的入门知识,它们内容不少,不知道大家消化得怎么样了呢?</p>
|
||
<p>这节课我们来学习一些字符串的进阶知识,掌握好本节课的内容,对你高效的使用字符串帮助颇大,我们依然提取最精练的内容传授给大家。</p>
|
||
<hr>
|
||
<h3 id="转义字符"><a name="转义字符" class="anchor-navigation-ex-anchor" href="#转义字符"><i class="fa fa-link" aria-hidden="true"></i></a>转义字符</h3>
|
||
<p>之前我们讲解过<code>\</code>符号可以作为转义字符。除了之前教学的场景之外,python还能支持一些其他的转义符,我们来列举常用的一些:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
<span class="token comment"># \n表示换行符,比较常用到</span>
|
||
a <span class="token operator">=</span> <span class="token string">"我是第一行\n我是第二行"</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span>
|
||
<span class="token comment"># 当我们要循环打出一段字符串的时候,不需要写多遍,用*号,后面加上重复的次数即可,比如这里打印40个*号</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">"*"</span> <span class="token operator">*</span> <span class="token number">40</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># \t表示制表符,类似你键盘上的Tab键的距离</span>
|
||
b <span class="token operator">=</span> <span class="token string">"我是第一行\t我是第二行"</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<p>上面的例子包含的知识点挺多哦,好好学习下。</p>
|
||
<p>其他还有一些自带支持的转义符我们就不一一列举了,感兴趣的同学可以自行找下资料。</p>
|
||
<hr>
|
||
<h3 id="格式化字符串"><a name="格式化字符串" class="anchor-navigation-ex-anchor" href="#格式化字符串"><i class="fa fa-link" aria-hidden="true"></i></a>格式化字符串</h3>
|
||
<p>还记得我们入门的时候,使用的是<code>+</code>号的方法把字符串联结起来,当遇到不同类型的数据的时候,我们需要把数据先转换成字符串型。这样有几点不便,其中的一点是,当字符串中的变量太多,需要写多个+号来联结,另一点是要经常关注数据类型,容易报错等。</p>
|
||
<p>这时候,我们更常用更常见的神器,格式化字符串,来了!</p>
|
||
<p>先来看下例子感受一下,我用了日常编程中更为常见的转换说明符来写:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
a <span class="token operator">=</span> <span class="token string">"我的名字是%s,我的年龄是%d。\n我知道,π的值为%.2f"</span> <span class="token operator">%</span> <span class="token punctuation">(</span><span class="token string">"小白"</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">,</span> <span class="token number">3.1415926</span><span class="token punctuation">)</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span>
|
||
b <span class="token operator">=</span> <span class="token string">"现在你在【%s】学习python小白课呢~"</span> <span class="token operator">%</span> <span class="token string">"雪山凌狐教程"</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<p>来我们来看一下,这两句示例代码都先用字符串定义了一串的内容,空格之后跟了一个<code>%</code>符号,再空格之后,对应的写入了一些内容,有的用括号括起来了,有的没用,对吧?</p>
|
||
<p>那么我们首先看一下第一部分的字符串内容,通过对比输出结果,我们可以看到,我们在字符串中也有<code>%</code>号,并且后面跟了一些字母等内容。接下来我们就来解释一下我们用到的几个转换说明符:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>转换说明符</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>%s</td>
|
||
<td>将内容(变量或者表达式)用str命令转换为字符串</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%d</td>
|
||
<td>转换为带符号的十进制形式的整数</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%f</td>
|
||
<td>转换为十进制形式的浮点数,.num表示保留小数点后面num位,如果给的值不够这个num大,则会补位</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>其他一些转换说明符还有,不过掌握几个常见的日常也基本够用了,这样大家记忆起来就不费力。如果你对其他的说明符感兴趣,可以自行查阅资料。</p>
|
||
<p>然后接下来是一个固定的<code>%</code>符号作为分隔符。</p>
|
||
<p>最后就是我们的内容了,内容可以直接写值也可以支持变量或者表达式的形式。如果前面的字符串定义了多个,需要用逗号<code>,</code>隔开,并且外面套上小括号,需要注意的是,前面定义了几个,后面就给几个,不要数量不正确,否则会报错哦。如果只定义了一个,那么直接写它就可以了。将一些内容用小括号括起来,在python中叫做<code>元组(tuple)</code>。有关元组的知识后面我们会另外再重点讲解,你稍微知道一下即可。</p>
|
||
<p>怎么样?是不是很方便?+号是不是少写了很多?</p>
|
||
<h3 id="format函数"><a name="format函数" class="anchor-navigation-ex-anchor" href="#format函数"><i class="fa fa-link" aria-hidden="true"></i></a>format函数</h3>
|
||
<p>这也是实战中用得比较多的格式化字符串的方法,我们来看个简单的例子就懂了:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
<span class="token comment"># format函数的参数中,可以带上参数名,可以不按顺序,如果不带参数名,就必须按顺序给值</span>
|
||
a <span class="token operator">=</span> <span class="token string">"我的名字是{name},我的年龄是{age}"</span><span class="token punctuation">.</span><span class="token builtin">format</span><span class="token punctuation">(</span>age<span class="token operator">=</span><span class="token number">18</span><span class="token punctuation">,</span> name<span class="token operator">=</span><span class="token string">"小白"</span><span class="token punctuation">)</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span>
|
||
<span class="token comment"># 也可以这样写和定义</span>
|
||
a <span class="token operator">=</span> <span class="token string">"我的名字是{},我的年龄是{}"</span><span class="token punctuation">.</span><span class="token builtin">format</span><span class="token punctuation">(</span><span class="token string">"小白"</span><span class="token punctuation">,</span> <span class="token number">98</span><span class="token punctuation">)</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<p>很简单,会了吗?用上<code>{}</code>大括号即可。</p>
|
||
<h3 id="f-string"><a name="f-string" class="anchor-navigation-ex-anchor" href="#f-string"><i class="fa fa-link" aria-hidden="true"></i></a>f-string</h3>
|
||
<p>上述的格式化方法是过去的版本python一直都有的,我们这里补充讲解一下据说是python3.6版本以上才新加的东东——<code>f-string</code>,让我们也来潮流一把。它可能比format函数更加顺畅哦。</p>
|
||
<p><code>f-string</code>,亦称为格式化字符串常量(formatted string literals),是Python3.6新引入的一种字符串格式化方法,主要目的是使格式化字符串的操作更加简便。</p>
|
||
<p>来我们直接看例子:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
name <span class="token operator">=</span> <span class="token string">"小白"</span>
|
||
age <span class="token operator">=</span> <span class="token number">18</span>
|
||
a <span class="token operator">=</span> <span class="token string-interpolation"><span class="token string">f"我的名字是</span><span class="token interpolation"><span class="token punctuation">{</span>name<span class="token punctuation">}</span></span><span class="token string">,我的年龄是</span><span class="token interpolation"><span class="token punctuation">{</span>age<span class="token punctuation">}</span></span><span class="token string">"</span></span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<p>其实在这里,大括号的作用是一个python表达式,你还可以在大括号里面写表达式的。基础使用我们就讲到这里吧,它的强大之处远远不止这些,如果你想深入了解,百度一下<code>f-string</code>即可得到很多你想要的答案了。</p>
|
||
<hr>
|
||
<h3 id="字符串索引及相关方法"><a name="字符串索引及相关方法" class="anchor-navigation-ex-anchor" href="#字符串索引及相关方法"><i class="fa fa-link" aria-hidden="true"></i></a>字符串索引及相关方法</h3>
|
||
<p>很多时候,我们仅需要取出一串字符串中的某些个内容,那么如何取出呢?这里我们来介绍一下索引的概念。</p>
|
||
<p>比如我们定义一个最简单的字符串:<code>a = "hello"</code>。</p>
|
||
<p>如果你算术够好,肯定能掰出五个手指头告诉我这里有<strong>5</strong>个字母。那么我们可以给他们每个字母编制一个索引。</p>
|
||
<blockquote>
|
||
<p>[!danger]</p>
|
||
<p>在python中,索引从<strong>0</strong>开始,务必记住!是0!不是1!很多编程语言的索引都从0开始(个别从1开始索引),这对于我们日常说一楼就是一楼的人有点难抽象出来,但定义如此,请你死记硬背好~</p>
|
||
</blockquote>
|
||
<p>所以,我们的五个字母的索引分别为:<code>0, 1, 2, 3, 4</code>。</p>
|
||
<p>我们用<code>[]</code>中括号表示索引,如果需要取出字母e,我们可以这样表示:<code>print(a[1])</code></p>
|
||
<p>我们还可以有其他写法,看例子:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
a <span class="token operator">=</span> <span class="token string">"hello"</span>
|
||
<span class="token comment"># 我们有如下索引对应关系:</span>
|
||
<span class="token comment"># [h -> 0], [e -> 1], [l -> 2], [l -> 3], [o -> 4]</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 取出从右边开始第1个字符</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 取出索引从2到4(不含4)的字符(即索引2~3的字符),注意写冒号的话永远是包含头索引不包含尾索引</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">:</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 取出倒数第3到倒数第1(不包含倒数第1)的字符串(不能反过来写哦)</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token operator">-</span><span class="token number">3</span><span class="token punctuation">:</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 取出索引为2之后的所有字符串</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">:</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 取出索引为1(不包含1)之前的所有字符串</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 用in运算符判断某字符串在不在原字符串里面,在返回True真,不在返回False假,这个布尔型我们之前讲过</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">"lo"</span> <span class="token keyword">in</span> a<span class="token punctuation">)</span>
|
||
<span class="token comment"># 获取字符的总长度,可以使用len函数</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token builtin">len</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 经过测试,对于中文字符串,它的数数也是按照英文字符串那样来数的,你可以自行深入测试</span>
|
||
b <span class="token operator">=</span> <span class="token string">"我是小白little bai"</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<hr>
|
||
<h3 id="字符串str类型自带的一些内置方法"><a name="字符串str类型自带的一些内置方法" class="anchor-navigation-ex-anchor" href="#字符串str类型自带的一些内置方法"><i class="fa fa-link" aria-hidden="true"></i></a>字符串str类型自带的一些内置方法</h3>
|
||
<p>字符串还有一些它内置的方法,让我们处理起字符串来可以得心应手。</p>
|
||
<p>我们可以通过<code>dir(str)</code>命令查看内置的方法有哪些,dir命令也能查看其它类的内置方法,这个大家可以自己探索下。运行后,会返回一个命令列表(list),关于列表的知识我们在后面的课程中会详细的讲解,大家稍微知道一下中括号括起来的是一个列表就可以了。</p>
|
||
<p>我这里运行结果如下:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token punctuation">[</span><span class="token string">'__add__'</span><span class="token punctuation">,</span> <span class="token string">'__class__'</span><span class="token punctuation">,</span> <span class="token string">'__contains__'</span><span class="token punctuation">,</span> <span class="token string">'__delattr__'</span><span class="token punctuation">,</span> <span class="token string">'__dir__'</span><span class="token punctuation">,</span> <span class="token string">'__doc__'</span><span class="token punctuation">,</span> <span class="token string">'__eq__'</span><span class="token punctuation">,</span> <span class="token string">'__format__'</span><span class="token punctuation">,</span> <span class="token string">'__ge__'</span><span class="token punctuation">,</span> <span class="token string">'__getattribute__'</span><span class="token punctuation">,</span> <span class="token string">'__getitem__'</span><span class="token punctuation">,</span> <span class="token string">'__getnewargs__'</span><span class="token punctuation">,</span> <span class="token string">'__gt__'</span><span class="token punctuation">,</span> <span class="token string">'__hash__'</span><span class="token punctuation">,</span> <span class="token string">'__init__'</span><span class="token punctuation">,</span> <span class="token string">'__init_subclass__'</span><span class="token punctuation">,</span> <span class="token string">'__iter__'</span><span class="token punctuation">,</span> <span class="token string">'__le__'</span><span class="token punctuation">,</span> <span class="token string">'__len__'</span><span class="token punctuation">,</span> <span class="token string">'__lt__'</span><span class="token punctuation">,</span> <span class="token string">'__mod__'</span><span class="token punctuation">,</span> <span class="token string">'__mul__'</span><span class="token punctuation">,</span> <span class="token string">'__ne__'</span><span class="token punctuation">,</span> <span class="token string">'__new__'</span><span class="token punctuation">,</span> <span class="token string">'__reduce__'</span><span class="token punctuation">,</span> <span class="token string">'__reduce_ex__'</span><span class="token punctuation">,</span> <span class="token string">'__repr__'</span><span class="token punctuation">,</span> <span class="token string">'__rmod__'</span><span class="token punctuation">,</span> <span class="token string">'__rmul__'</span><span class="token punctuation">,</span> <span class="token string">'__setattr__'</span><span class="token punctuation">,</span> <span class="token string">'__sizeof__'</span><span class="token punctuation">,</span> <span class="token string">'__str__'</span><span class="token punctuation">,</span> <span class="token string">'__subclasshook__'</span><span class="token punctuation">,</span> <span class="token string">'capitalize'</span><span class="token punctuation">,</span> <span class="token string">'casefold'</span><span class="token punctuation">,</span> <span class="token string">'center'</span><span class="token punctuation">,</span> <span class="token string">'count'</span><span class="token punctuation">,</span> <span class="token string">'encode'</span><span class="token punctuation">,</span> <span class="token string">'endswith'</span><span class="token punctuation">,</span> <span class="token string">'expandtabs'</span><span class="token punctuation">,</span> <span class="token string">'find'</span><span class="token punctuation">,</span> <span class="token string">'format'</span><span class="token punctuation">,</span> <span class="token string">'format_map'</span><span class="token punctuation">,</span> <span class="token string">'index'</span><span class="token punctuation">,</span> <span class="token string">'isalnum'</span><span class="token punctuation">,</span> <span class="token string">'isalpha'</span><span class="token punctuation">,</span> <span class="token string">'isascii'</span><span class="token punctuation">,</span> <span class="token string">'isdecimal'</span><span class="token punctuation">,</span> <span class="token string">'isdigit'</span><span class="token punctuation">,</span> <span class="token string">'isidentifier'</span><span class="token punctuation">,</span> <span class="token string">'islower'</span><span class="token punctuation">,</span> <span class="token string">'isnumeric'</span><span class="token punctuation">,</span> <span class="token string">'isprintable'</span><span class="token punctuation">,</span> <span class="token string">'isspace'</span><span class="token punctuation">,</span> <span class="token string">'istitle'</span><span class="token punctuation">,</span> <span class="token string">'isupper'</span><span class="token punctuation">,</span> <span class="token string">'join'</span><span class="token punctuation">,</span> <span class="token string">'ljust'</span><span class="token punctuation">,</span> <span class="token string">'lower'</span><span class="token punctuation">,</span> <span class="token string">'lstrip'</span><span class="token punctuation">,</span> <span class="token string">'maketrans'</span><span class="token punctuation">,</span> <span class="token string">'partition'</span><span class="token punctuation">,</span> <span class="token string">'replace'</span><span class="token punctuation">,</span> <span class="token string">'rfind'</span><span class="token punctuation">,</span> <span class="token string">'rindex'</span><span class="token punctuation">,</span> <span class="token string">'rjust'</span><span class="token punctuation">,</span> <span class="token string">'rpartition'</span><span class="token punctuation">,</span> <span class="token string">'rsplit'</span><span class="token punctuation">,</span> <span class="token string">'rstrip'</span><span class="token punctuation">,</span> <span class="token string">'split'</span><span class="token punctuation">,</span> <span class="token string">'splitlines'</span><span class="token punctuation">,</span> <span class="token string">'startswith'</span><span class="token punctuation">,</span> <span class="token string">'strip'</span><span class="token punctuation">,</span> <span class="token string">'swapcase'</span><span class="token punctuation">,</span> <span class="token string">'title'</span><span class="token punctuation">,</span> <span class="token string">'translate'</span><span class="token punctuation">,</span> <span class="token string">'upper'</span><span class="token punctuation">,</span> <span class="token string">'zfill'</span><span class="token punctuation">]</span>
|
||
</code></pre>
|
||
<blockquote>
|
||
<p>[!note]</p>
|
||
<p>方法有很多,其中我们注意到有很多方法开头结尾都有<code>__</code>双下划线符号,这些命令为python系统定义的名字,是特殊方法专用的标识,请不要自己随意定义这类命令。</p>
|
||
</blockquote>
|
||
<p>剩下的那些就是内置类方法啦,里面太多了,如果你感兴趣,可以使用我们学过的help命令来查看帮助文档哦。我们来挑一些重点的来写示例讲解:</p>
|
||
<pre class="language-"><code class="lang-python"><span class="token comment"># coding:utf-8</span>
|
||
<span class="token comment"># 大小写相关方法</span>
|
||
a <span class="token operator">=</span> <span class="token string">"my name is liTTle bai 小白"</span>
|
||
<span class="token comment"># title方法,将每个单词首字母改为大写</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># lower方法,将每个字母改为小写。比如在比较文件后缀名时十分有用</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">.</span>lower<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># upper方法,将每个字母改为大写</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>a<span class="token punctuation">.</span>upper<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
|
||
<span class="token comment"># 删除空白相关方法,空格,制表符等都可以</span>
|
||
b <span class="token operator">=</span> <span class="token string">" my name is liTTle bai 小白 "</span>
|
||
<span class="token comment"># strip方法,删除首尾的空白</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">.</span>strip<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># lstrip方法,删除左边left的空白</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">.</span>lstrip<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># rstrip方法,删除右边right的空白</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">.</span>rstrip<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># 补充一句,这些方法有时候是可以嵌套的,不用写多行来处理,比如先变小写再删首尾空</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>b<span class="token punctuation">.</span>lower<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>strip<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
|
||
<span class="token comment"># 查找替换相关方法</span>
|
||
c <span class="token operator">=</span> <span class="token string">"my name is little bai 小白"</span>
|
||
<span class="token comment"># startswith方法,判断字符串是不是以传入的参数开头,会返回布尔型返回值真或假</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>c<span class="token punctuation">.</span>startswith<span class="token punctuation">(</span><span class="token string">"my"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># endswith方法,判断字符串是不是以传入的参数结尾,会返回布尔型返回值真或假</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>c<span class="token punctuation">.</span>endswith<span class="token punctuation">(</span><span class="token string">"bai"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># find方法,获取参数在字符串中出现的位置索引,没有找到返回-1</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>c<span class="token punctuation">.</span>find<span class="token punctuation">(</span><span class="token string">"is"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># replace方法,将字符串中的某些内容(如有),替换成别的内容</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>c<span class="token punctuation">.</span>replace<span class="token punctuation">(</span><span class="token string">"小白"</span><span class="token punctuation">,</span> <span class="token string">"小黑"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
|
||
<span class="token comment"># 分割、连接方法</span>
|
||
<span class="token comment"># split方法,将字符串按照指定的分割符分割文本,默认分割符(如果不写)为空格(可以是多个空格)</span>
|
||
d <span class="token operator">=</span> <span class="token string">"my name is liTTle bai 小白"</span> <span class="token comment"># 出来的结果是一个列表list,后面我们可以再做详细讲解如何后续处理</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span>d<span class="token punctuation">.</span>split<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
<span class="token comment"># join方法,刚才分割的反向操作,把一个列表的每个元素(列表中逗号分隔开的一个个称作元素)</span>
|
||
<span class="token comment"># 按照指定的连接符(比如点号.)连接起来</span>
|
||
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">.</span>join<span class="token punctuation">(</span>d<span class="token punctuation">.</span>split<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||
</code></pre>
|
||
<p>说了这么多,可能大家都已经有些晕晕乎乎的了。不过没关系,本节课值得大家细细品味,如果一遍没有掌握,请多回来看几遍,记住常用的那些命令的单词,当你需要的时候就很容易了,它们的使用都是相当简单的。</p>
|
||
<h3 id="单词释义"><a name="单词释义" class="anchor-navigation-ex-anchor" href="#单词释义"><i class="fa fa-link" aria-hidden="true"></i></a>单词释义</h3>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>单词</th>
|
||
<th>释义</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Tab</td>
|
||
<td>这里指键盘上的Tab键,会输出一个制表符\t</td>
|
||
</tr>
|
||
<tr>
|
||
<td>num</td>
|
||
<td>number数字的简写</td>
|
||
</tr>
|
||
<tr>
|
||
<td>tuple</td>
|
||
<td>元组</td>
|
||
</tr>
|
||
<tr>
|
||
<td>format</td>
|
||
<td>格式化</td>
|
||
</tr>
|
||
<tr>
|
||
<td>formatted string literals</td>
|
||
<td>格式化字符串常量</td>
|
||
</tr>
|
||
<tr>
|
||
<td>dir</td>
|
||
<td>全称为directory,你可以理解为目录,罗列出来</td>
|
||
</tr>
|
||
<tr>
|
||
<td>list</td>
|
||
<td>列表</td>
|
||
</tr>
|
||
<tr>
|
||
<td>in</td>
|
||
<td>在...里面</td>
|
||
</tr>
|
||
<tr>
|
||
<td>len</td>
|
||
<td>length长度的简洁写法,这里是一个命令名</td>
|
||
</tr>
|
||
<tr>
|
||
<td>title</td>
|
||
<td>标题,这里是一个命令名</td>
|
||
</tr>
|
||
<tr>
|
||
<td>lower</td>
|
||
<td>下面的</td>
|
||
</tr>
|
||
<tr>
|
||
<td>upper</td>
|
||
<td>上面的</td>
|
||
</tr>
|
||
<tr>
|
||
<td>strip</td>
|
||
<td>除去,剥去</td>
|
||
</tr>
|
||
<tr>
|
||
<td>lstrip</td>
|
||
<td>应该是left strip的简写,left为左边</td>
|
||
</tr>
|
||
<tr>
|
||
<td>rstrip</td>
|
||
<td>应该是right strip的简写,right为右边</td>
|
||
</tr>
|
||
<tr>
|
||
<td>startswith</td>
|
||
<td>start开始,with结合上下文理解为跟着啥</td>
|
||
</tr>
|
||
<tr>
|
||
<td>endswith</td>
|
||
<td>end结束,with结合上下文理解为跟着啥</td>
|
||
</tr>
|
||
<tr>
|
||
<td>find</td>
|
||
<td>寻找</td>
|
||
</tr>
|
||
<tr>
|
||
<td>replace</td>
|
||
<td>替换</td>
|
||
</tr>
|
||
<tr>
|
||
<td>split</td>
|
||
<td>分割,分裂</td>
|
||
</tr>
|
||
<tr>
|
||
<td>join</td>
|
||
<td>连接,加入</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<footer class="page-footer"><span class="copyright">Copyright © <a href="http://fox-9.com" target="_blank">雪山凌狐教程</a> all right reserved,powered by Gitbook</span><span class="footer-modification">该文件修订时间:
|
||
2020-09-19 12:35:13
|
||
</span></footer></body></html>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
<div class="search-results">
|
||
<div class="has-results">
|
||
|
||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||
<ul class="search-results-list"></ul>
|
||
|
||
</div>
|
||
<div class="no-results">
|
||
|
||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<a href="2-8 python3小白课:字节串.html" class="navigation navigation-prev " aria-label="Previous page: 2-8 python3小白课:字节串">
|
||
<i class="fa fa-angle-left"></i>
|
||
</a>
|
||
|
||
|
||
<a href="2-10 python3小白课:赋值运算符.html" class="navigation navigation-next " aria-label="Next page: 2-10 python3小白课:赋值运算符">
|
||
<i class="fa fa-angle-right"></i>
|
||
</a>
|
||
|
||
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var gitbook = gitbook || [];
|
||
gitbook.push(function() {
|
||
gitbook.page.hasChanged({"page":{"title":"2-9 python3小白课:字符串进阶","level":"1.4.9","depth":2,"next":{"title":"2-10 python3小白课:赋值运算符","level":"1.4.10","depth":2,"path":"chapter2/2-10 python3小白课:赋值运算符.md","ref":"./chapter2/2-10 python3小白课:赋值运算符.md","articles":[]},"previous":{"title":"2-8 python3小白课:字节串","level":"1.4.8","depth":2,"path":"chapter2/2-8 python3小白课:字节串.md","ref":"./chapter2/2-8 python3小白课:字节串.md","articles":[]},"dir":"ltr"},"config":{"plugins":["favicon","-search","-lunr","-sharing","-livereload","-highlight","prism","prism-themes","fontsettings","back-to-top-button","expandable-chapters-small","code","search-pro","splitter","donate","tbfed-pagefooter","pageview-count","auto-scroll-table","lightbox","anchor-navigation-ex","sitemap-general","ad","image-captions","autotheme","advanced-emoji","flexible-alerts","statistics","push-bd"],"styles":{"website":"/css/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © <a href='http://fox-9.com'>雪山凌狐教程</a>","modify_label":"该文件修订时间:","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-material-light.css"]},"ad":{"contentBottom":false},"statistics":{"bd_url":"https://hm.baidu.com/hm.js","cnzz_url":"https://s95.cnzz.com/z_stat.php","google_url":"https://www.googletagmanager.com/gtag/js","bd_token":"605d1993c133629d69ab2701f78d9690"},"splitter":{},"search-pro":{},"auto-scroll-table":{},"code":{"copyButtons":true},"donate":{"alipay":"/python3xiaobaike/assets/alipay-code.jpg","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"/python3xiaobaike/assets/wechatpay-code.jpg","wechatText":"微信打赏"},"sitemap-general":{"prefix":"http://doc.fox-9.com/python3xiaobaike/"},"fontsettings":{"family":"sans","size":2,"theme":"white"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right","showLevelIcon":true},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"favicon":{"shortcut":"/assets/favicon.ico","bookmark":"/assets/favicon.ico"},"lightbox":{"jquery":true,"sameUuid":false},"push-bd":{},"back-to-top-button":{},"pageview-count":{},"prism-themes":{},"expandable-chapters-small":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"注意"},"note":{"className":"info","icon":"fa fa-info-circle","label":"说明"},"style":"flat","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"提示"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"警告"},"question":{"label":"问题","icon":"fa fa-question-circle","className":"question"}},"autotheme":{"night":[20,21,22,23,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"sepia":[25,25,25,25,25,25],"white":[25,25,25,25,25,25,25,25]},"advanced-emoji":{"embedEmojis":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"image-captions":{"caption":"_CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"雪山凌狐","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"CATALOG_FOR_GITBOOK.md"},"variables":{"_pictures":[{"backlink":"./chapter1/1-1 python3小白课:python语言简介.html#fig1.3.1.1","level":"1.3.1","list_caption":"Figure: 图1-1-1 龟叔","alt":"图1-1-1 龟叔","nro":1,"url":"assets/1-1-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图1-1-1 龟叔","attributes":{},"skip":false,"key":"1.3.1.1"},{"backlink":"./chapter1/1-1 python3小白课:python语言简介.html#fig1.3.1.2","level":"1.3.1","list_caption":"Figure: 图1-1-2 python2的最后一个版本官方博客","alt":"图1-1-2 python2的最后一个版本官方博客","nro":2,"url":"assets/1-1-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图1-1-2 python2的最后一个版本官方博客","attributes":{},"skip":false,"key":"1.3.1.2"},{"backlink":"./chapter1/1-2 python3小白课:python下载.html#fig1.3.2.1","level":"1.3.2","list_caption":"Figure: 图1-2-1 python官网界面","alt":"图1-2-1 python官网界面","nro":3,"url":"assets/1-2-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图1-2-1 python官网界面","attributes":{},"skip":false,"key":"1.3.2.1"},{"backlink":"./chapter1/1-2 python3小白课:python下载.html#fig1.3.2.2","level":"1.3.2","list_caption":"Figure: 图1-2-2 python3.8.2版本安装包","alt":"图1-2-2 python3.8.2版本安装包","nro":4,"url":"assets/1-2-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图1-2-2 python3.8.2版本安装包","attributes":{},"skip":false,"key":"1.3.2.2"},{"backlink":"./chapter1/1-3 python3小白课:python安装.html#fig1.3.3.1","level":"1.3.3","list_caption":"Figure: 图1-3-1 安装界面1","alt":"图1-3-1 安装界面1","nro":5,"url":"assets/1-3-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图1-3-1 安装界面1","attributes":{},"skip":false,"key":"1.3.3.1"},{"backlink":"./chapter1/1-3 python3小白课:python安装.html#fig1.3.3.2","level":"1.3.3","list_caption":"Figure: 图1-3-2 安装界面2","alt":"图1-3-2 安装界面2","nro":6,"url":"assets/1-3-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图1-3-2 安装界面2","attributes":{},"skip":false,"key":"1.3.3.2"},{"backlink":"./chapter1/1-3 python3小白课:python安装.html#fig1.3.3.3","level":"1.3.3","list_caption":"Figure: 图1-3-3 安装界面3","alt":"图1-3-3 安装界面3","nro":7,"url":"assets/1-3-3.jpg","index":3,"caption_template":"_CAPTION_","label":"图1-3-3 安装界面3","attributes":{},"skip":false,"key":"1.3.3.3"},{"backlink":"./chapter1/1-6 python3小白课:使用python IDLE.html#fig1.3.6.1","level":"1.3.6","list_caption":"Figure: 图1-6-1 python shell","alt":"图1-6-1 python shell","nro":8,"url":"assets/1-6-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图1-6-1 python shell","attributes":{},"skip":false,"key":"1.3.6.1"},{"backlink":"./chapter1/1-6 python3小白课:使用python IDLE.html#fig1.3.6.2","level":"1.3.6","list_caption":"Figure: 图1-6-2 python IDLE写py文件","alt":"图1-6-2 python IDLE写py文件","nro":9,"url":"assets/1-6-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图1-6-2 python IDLE写py文件","attributes":{},"skip":false,"key":"1.3.6.2"},{"backlink":"./chapter1/1-7 python3小白课:使用python shell.html#fig1.3.7.1","level":"1.3.7","list_caption":"Figure: 图1-7-1 进入python shell","alt":"图1-7-1 进入python shell","nro":10,"url":"assets/1-7-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图1-7-1 进入python shell","attributes":{},"skip":false,"key":"1.3.7.1"},{"backlink":"./chapter1/1-7 python3小白课:使用python shell.html#fig1.3.7.2","level":"1.3.7","list_caption":"Figure: 图1-7-2 python shell代码测试","alt":"图1-7-2 python shell代码测试","nro":11,"url":"assets/1-7-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图1-7-2 python shell代码测试","attributes":{},"skip":false,"key":"1.3.7.2"},{"backlink":"./chapter6/6-8 python3小白课:解锁你心仪的三方包.html#fig1.8.8.1","level":"1.8.8","list_caption":"Figure: 图6-8-1 pypi官网首页","alt":"图6-8-1 pypi官网首页","nro":12,"url":"assets/6-8-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图6-8-1 pypi官网首页","attributes":{},"skip":false,"key":"1.8.8.1"},{"backlink":"./chapter6/6-8 python3小白课:解锁你心仪的三方包.html#fig1.8.8.2","level":"1.8.8","list_caption":"Figure: 图6-8-2 requests搜索结果","alt":"图6-8-2 requests搜索结果","nro":13,"url":"assets/6-8-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图6-8-2 requests搜索结果","attributes":{},"skip":false,"key":"1.8.8.2"},{"backlink":"./chapter6/6-8 python3小白课:解锁你心仪的三方包.html#fig1.8.8.3","level":"1.8.8","list_caption":"Figure: 图6-8-3 包的内页","alt":"图6-8-3 包的内页","nro":14,"url":"assets/6-8-3.jpg","index":3,"caption_template":"_CAPTION_","label":"图6-8-3 包的内页","attributes":{},"skip":false,"key":"1.8.8.3"},{"backlink":"./chapter6/6-8 python3小白课:解锁你心仪的三方包.html#fig1.8.8.4","level":"1.8.8","list_caption":"Figure: 图6-8-4 下载文件页面","alt":"图6-8-4 下载文件页面","nro":15,"url":"assets/6-8-4.jpg","index":4,"caption_template":"_CAPTION_","label":"图6-8-4 下载文件页面","attributes":{},"skip":false,"key":"1.8.8.4"},{"backlink":"./chapter6/6-9 python3小白课:虚拟环境介绍和安装.html#fig1.8.9.1","level":"1.8.9","list_caption":"Figure: 图6-9-1 新建系统环境变量WORKON_HOME","alt":"图6-9-1 新建系统环境变量WORKON_HOME","nro":16,"url":"assets/6-9-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图6-9-1 新建系统环境变量WORKON_HOME","attributes":{},"skip":false,"key":"1.8.9.1"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.1","level":"1.8.10","list_caption":"Figure: 图6-10-1 创建test虚拟环境","alt":"图6-10-1 创建test虚拟环境","nro":17,"url":"assets/6-10-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图6-10-1 创建test虚拟环境","attributes":{},"skip":false,"key":"1.8.10.1"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.2","level":"1.8.10","list_caption":"Figure: 图6-10-2 退出虚拟环境","alt":"图6-10-2 退出虚拟环境","nro":18,"url":"assets/6-10-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图6-10-2 退出虚拟环境","attributes":{},"skip":false,"key":"1.8.10.2"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.3","level":"1.8.10","list_caption":"Figure: 图6-10-3 workon激活虚拟环境test","alt":"图6-10-3 workon激活虚拟环境test","nro":19,"url":"assets/6-10-3.jpg","index":3,"caption_template":"_CAPTION_","label":"图6-10-3 workon激活虚拟环境test","attributes":{},"skip":false,"key":"1.8.10.3"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.4","level":"1.8.10","list_caption":"Figure: 图6-10-4 虚拟环境下的pip","alt":"图6-10-4 虚拟环境下的pip","nro":20,"url":"assets/6-10-4.jpg","index":4,"caption_template":"_CAPTION_","label":"图6-10-4 虚拟环境下的pip","attributes":{},"skip":false,"key":"1.8.10.4"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.5","level":"1.8.10","list_caption":"Figure: 图6-10-5 删除虚拟环境test","alt":"图6-10-5 删除虚拟环境test","nro":21,"url":"assets/6-10-5.jpg","index":5,"caption_template":"_CAPTION_","label":"图6-10-5 删除虚拟环境test","attributes":{},"skip":false,"key":"1.8.10.5"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.6","level":"1.8.10","list_caption":"Figure: 图6-10-6 python3.6.6安装","alt":"图6-10-6 python3.6.6安装","nro":22,"url":"assets/6-10-6.jpg","index":6,"caption_template":"_CAPTION_","label":"图6-10-6 python3.6.6安装","attributes":{},"skip":false,"key":"1.8.10.6"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.7","level":"1.8.10","list_caption":"Figure: 图6-10-7 创建python3.6.6的虚拟环境","alt":"图6-10-7 创建python3.6.6的虚拟环境","nro":23,"url":"assets/6-10-7.jpg","index":7,"caption_template":"_CAPTION_","label":"图6-10-7 创建python3.6.6的虚拟环境","attributes":{},"skip":false,"key":"1.8.10.7"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.8","level":"1.8.10","list_caption":"Figure: 图6-10-8 python2.7.18安装","alt":"图6-10-8 python2.7.18安装","nro":24,"url":"assets/6-10-8.jpg","index":8,"caption_template":"_CAPTION_","label":"图6-10-8 python2.7.18安装","attributes":{},"skip":false,"key":"1.8.10.8"},{"backlink":"./chapter6/6-10 python3小白课:虚拟环境使用.html#fig1.8.10.9","level":"1.8.10","list_caption":"Figure: 图6-10-9 创建python2.7.18的虚拟环境","alt":"图6-10-9 创建python2.7.18的虚拟环境","nro":25,"url":"assets/6-10-9.jpg","index":9,"caption_template":"_CAPTION_","label":"图6-10-9 创建python2.7.18的虚拟环境","attributes":{},"skip":false,"key":"1.8.10.9"},{"backlink":"./chapter7/7-1 python3小白课:一节课搞懂面向对象.html#fig1.9.1.1","level":"1.9.1","list_caption":"Figure: 图7-1-1 暖风机","alt":"图7-1-1 暖风机","nro":26,"url":"assets/7-1-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图7-1-1 暖风机","attributes":{},"skip":false,"key":"1.9.1.1"},{"backlink":"./chapter7/7-1 python3小白课:一节课搞懂面向对象.html#fig1.9.1.2","level":"1.9.1","list_caption":"Figure: 图7-1-2 会摇头的暖风机","alt":"图7-1-2 会摇头的暖风机","nro":27,"url":"assets/7-1-2.jpg","index":2,"caption_template":"_CAPTION_","label":"图7-1-2 会摇头的暖风机","attributes":{},"skip":false,"key":"1.9.1.2"},{"backlink":"./chapter7/7-1 python3小白课:一节课搞懂面向对象.html#fig1.9.1.3","level":"1.9.1","list_caption":"Figure: 图7-1-3 会摇头的冷风机","alt":"图7-1-3 会摇头的冷风机","nro":28,"url":"assets/7-1-3.jpg","index":3,"caption_template":"_CAPTION_","label":"图7-1-3 会摇头的冷风机","attributes":{},"skip":false,"key":"1.9.1.3"},{"backlink":"./chapter7/7-7 python3小白课:重写父类方法和使用super函数.html#fig1.9.7.1","level":"1.9.7","list_caption":"Figure: 图7-7-1 鸡的图片","alt":"图7-7-1 鸡的图片","nro":29,"url":"assets/7-7-1.jpg","index":1,"caption_template":"_CAPTION_","label":"图7-7-1 鸡的图片","attributes":{},"skip":false,"key":"1.9.7.1"}]},"title":"python3小白课笔记","language":"zh-hans","links":{"sidebar":{"雪山凌狐教程":"http://fox-9.com"}},"gitbook":"3.2.3","description":"python3小白课,让你不再惧怕python的入门学习"},"file":{"path":"chapter2/2-9 python3小白课:字符串进阶.md","mtime":"2020-09-19T04:35:13.290Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-09-14T10:02:56.416Z"},"basePath":"..","book":{"language":""}});
|
||
});
|
||
</script>
|
||
</div>
|
||
|
||
|
||
<script src="../gitbook/gitbook.js"></script>
|
||
<script src="../gitbook/theme.js"></script>
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-auto-scroll-table/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-ad/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-autotheme/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-statistics/statistics.js"></script>
|
||
|
||
|
||
|
||
<script src="../gitbook/gitbook-plugin-push-bd/plugin.js"></script>
|
||
|
||
|
||
|
||
</body>
|
||
</html>
|
||
|