Python考前复习

选择题易错:

  • python3不能完全兼容python2
  • 内置函数是python的内置对象之一,无需导入其他模块
  • python中汉字变量合法,如"小李=123"合法;但T-C不合法,因为有"-"
  • 集合无顺序,不能索引;range(5)2=2,可以索引
  • list1=list2之后,两个列表指向同一个内存空间,改变其中一个的值,另一个随之改变;但是要注意list2全部改变的情况
python 复制代码
>>> list1=[2,4,6] 
>>> list2=list1 

>>> list2[1]=5 
>>> list1 
[2, 5, 6]//改变list2,list1也变了 

>>> list2=[1,2,3] 
>>> list1 
[2, 5, 6]//当list2全部改变(相当于重新赋值了另一个列表),则list1不变
  • 区分s.find()和s.index(),二者都用来找字符串中子串的位置,但find找不到返回-1,index找不到则报错
相关推荐
金銀銅鐵2 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf2 小时前
Agent 流程编排
后端·python·agent
copyer_xyf3 小时前
Agent RAG
后端·python·agent
copyer_xyf3 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf3 小时前
Agent 记忆管理
后端·python·agent
星云穿梭18 小时前
用Python写一个带图形界面的学生管理系统——完整教程
python
金銀銅鐵19 小时前
用 Pygame 实现 15 puzzle
python·数学·游戏
黄忠1 天前
大模型之LangGraph技术体系
python·llm
hboot2 天前
AI工程师第二课 - 数据处理
人工智能·python·数据分析
用户8356290780512 天前
使用 Python 自动化 PowerPoint 形状布局与格式设置
后端·python