摘要: Debugging 关于debug的方法 1.使用print语句打印变量的值 2.使用assert语句判断程序的错误 3.使用pdb模块,(Python的调试器)可以在程序中设置断点,单步调试 4.使用IDE的内置调试器 5.向人工智能求助 常见错误 1.缩进错误 切忌tab和空格混用 2.语法错误 阅读全文
posted @ 2023-12-07 21:46 liuyecheng 阅读(17) 评论(0) 推荐(0)
摘要: 循环和字符串 循环 for循环 for x in range(x,y) for x in range(1,10,2): print(int(x)) 表示遍历1到9之间的数,步长为2 即打印1 3 5 7 9 while循环 while(条件): 执行行为 while True: print("nih 阅读全文
posted @ 2023-12-02 18:47 liuyecheng 阅读(19) 评论(0) 推荐(0)
摘要: 条件 if else语句 if 条件: 执行行为 else: 执行行为 elif语句: 等同与c语言中的else i语句 if x>10: print() elif x=10: print(2) else: print(3) if else推导式 print(n if(n>0) else -n) m 阅读全文
posted @ 2023-11-28 19:09 liuyecheng 阅读(22) 评论(0) 推荐(0)
摘要: 笔记 数据类型 int 整型 float 浮点型 bool 布尔型 True 和False 表示 and运算是与运算,只有所有都为True,and运算结果才是True or运算是或运算,只要其中有一个为True,or运算结果就是True not运算是非运算,它是一个单目运算符,把True变成Fals 阅读全文
posted @ 2023-11-25 20:28 liuyecheng 阅读(16) 评论(0) 推荐(0)
摘要: python 注释语法: 单行注释:使用#开头 多行注释:使用"""或'''包裹代码 养成写注释的好习惯 print("hello world") #print("nihao") """ print("hello world") print("nihao") """ 代码常见错误: 逻辑错误 运行错 阅读全文
posted @ 2023-11-21 21:37 liuyecheng 阅读(27) 评论(0) 推荐(0)