(没有学会破解版所以只能简单文字记了)
→File
→New Project
→Pure Python 修改项目名称
→open in current window+Add……
→New python file
例如:#打印 helloword
例如:
int、folat、bool、str、tuple、list、dict、set、complex
(和 C 不同的是,int和float没有那么多限制,可以存很大的数)
(和 C 的规范类似,标识符是字母数字下划线,数字不能开头,不能是关键字)
关键字:False、Ture、(注意开头字母大写)and、as、assert、break、class、continue、def、del、elif、else、except、finally、for、from、global、if、import、in、is、lambda、nonlocal、not、or、pass、raise、return、try、while、with、yield
书写符号时前后空格更美观规范
注意:
类似C的与、或、非,返回T或F
【 按ctrl可查看函数功能】
【 id (a) 可返回a的地址】
a = 'asd'
b = 'asd'
c = ''' asd '''
(回车也占用字符长度)d = """ asd """
#例:
a='helloword!'
print(a[3])#从0位开始排序 0、1、2……
print(a[-1]#倒序排序,最后一位为-1,往前依次-2、-3……
print(a[1:5])#起始位为1,终止位为5,且取不到末位 输出ello
print(a[1:7:1])#最后一个数字代表步长 输出ellowo
print(a[1:7:2])#输出elw
print(a[-1::-1])#(终止位可省略)倒序输出!drowolleh
字符串可看作常量,不支持单个字符修改,如令 a[0]=p 会报错,但列表list可以
#例:
a='hello'
"""
a.r just(长度,"x")改变长度,不足用x补足
"""
print(a.r just(10,"+") #输出+++++hello
'''
a.endswith("x")判断是否以x结尾,返回True或Flase
'''
print(a.endswith("llo")#返回True
'''
a.index("x")返回x首次出现的下标,找不到报错
a.find("x")返回x首次出现的下标,找不到返回-1
'''
#例:
a=["小明",18,"男",180,160,3.14]
b=[1,2,3,4]
print(len(a))#输出6
b=a.copy()#分为浅拷贝和深拷贝
print(a+b)
a[2]=True
print(a)#输出 ["小明",18,True,180,160,3.14]
for a_ in a:
print(a_)
'''
输出:
小明
18
男
180
160
3.14
'''
排序的八大算法:冒泡排序、快速排序、插入排序、选择排序、堆排序、希尔排序、归并排序、基数排序
#例 1
a=[5,9,8,6,4,7,3,0]
a.sort()
print(a)#输出 [0,3,4,5,6,7,8,9]
冒泡排序:
a=[5,9,8,6,4,7,3,0]
for i in range(len(a)-1)
for j in range(len(a)-1-i)
if a[j] > a[j+1]
a[j],a[j+1]=a[j+1],a[j]
最后…………………………
我还没有看 也没有买……
【新手笔记,欢迎指点修正】——Dangerous
本文地址:https://blog.csdn.net/RK_Dangerous/article/details/107174523
如对本文有疑问, 点击进行留言回复!!
VSCode出现ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)错误
从零开始的PYTHON3摸鱼(二)windows如何运行python,编辑器选择
网友评论