导图社区 python 教程学习笔记
纯干货!你要的Python基础知识点整理好了!本文对Python的入门基础知识、变量和简单数据模型、简单列表秒速这些方面进行了全量笔记整理。
社区模板帮助中心,点此进入>>
互联网9大思维
组织架构-单商户商城webAPP 思维导图。
域控上线
python思维导图
css
CSS
计算机操作系统思维导图
计算机组成原理
IMX6UL(A7)
考试学情分析系统
Python
编辑器
geany
sublime texe
python
文件格式为py结尾
hello world:print("hello python world!)
cad可以打开PY文件
CMD打开电脑文件
子主题
1.d:+enter表示打开D盘
2.输入文件夹名称,enter打开
3.输入PY文件名称,打开文件内容
变量和简单数据类型
message =("python")
message只记录最新值
name = "python"
变量tittle
print(name.title())打印出name值,且首字母为大写
变量upper
print(name.upper())打印出全大写name值
变量lower
print(name.lower())打印出全小写name字符串
full_name
frise_name="ada"
last_name="love"
full_name=frist_name+" "+last_name
print(full_name)输出为:ada love
注:空格要打引号
EG:print(”hello,“+full_name.title()+"!"
也可以吧整条消息储存在message中,用print输出
\t
\t 可以添加制表符
print("\tpythone\taaa\tbbb")输出为python aaa bbb
\n可添加分列符
eg:prin(eg;\naaa\nbbb\nccc)输出为
\t和\n可以起使用添加制表符和分列符
删除空格
favorite_language.strip()
去除右边空白
favorite_language = "pythone " favorite_language=favorite_language.rstrip() print(favorite_language)
favorite_language.Ltrip()
去除左边空白
favorite_language = "pythone " favorite_language=favorite_language.lstrip() print(favorite_language)
favorite_language.trip()
去除两边空白
favorite_language = "pythone " favorite_language=favorite_language.strip() print(favorite_language)
python支持四则运算
+ - * /
**表示乘方运算3**3表示3的3次方
带小数点的数叫浮点数
python运算带小数点的可能不准确
str
将非字符串表示字符串
eg:age = 23 python不知道是23还是2和3
可以用str(23)表示23为一个整体
#
#后面的内容会被python忽略
#表示注释
列表
bycicles索引
bycicles = ["a","b","c","d"]
print(bycicles[0])表示索引bycicles中的首个值,
print(bycicles[-1]}表表示索引出bycicles中的倒数第一个值
motorcycle
motrcycle可以修改字符串中的内容
eg:motorcycles = ["A","B","C","D"] print(motorcycles)输出A B C D
otorcycles[0]="XX" print(motorcycles)输出XX B C D
append 将内容添加到列表末尾
eg:motorcycles = ["A","B","C","D"] print(motorcycles) motorcycles.append("zz") print(motorcycles)
输出为:A B C D和A B C D ZZ
motorcycles = [] motorcycles.append("zz") motorcycles.append("yy") motorcycles.append("aa") print(motorcycles)
输出为zz yy aa
insert
将内容添加到列表里
eg:motorcycles = ["A","B","C","D"] print(motorcycles) eg:motorcycles.insert(0,"XX") print(motorcycles)
输出为A B C D 和XX A B C D 在列表0的位置中添加了XX字符
del
删除列表中的元素
motorcycles = ["A","B","C","D"] print(motorcycles) del (motorcycles)[0] print(motorcycles)
输出内容为A B C D和B C D,删除了列表中位置0的元素
poped
删除尾部元素
motorcycles = ["A","B","C","D"] poped_motorcyles= motorcycles.pop() print(motorcycles) print(poped_motorcyles)
输出motorcycles为
A B C D
A B C
D
删除部分内容D储存在poped_motorcyles中