摘要: 数字:Python3中不管有多大的数字,都是int类型;Python2中,短的用int(整型),超过一定程度,用long(长整型) a1=123 功能1:类型转换 a="123"print(type(a),a)b=int(a)print(type(b),b) 功能2:进制转换:将字符串转换为数字,并 阅读全文
posted @ 2025-06-08 16:29 大猫学编程 阅读(12) 评论(0) 推荐(0)
摘要: 加 + 减 - 乘 * 除 / 等 = 乘方 ** 取余 % 取整 // 包含 in name="凤凰传奇" if "凤凰" in name: print("<OK>") else: print("<error>") 不包含 not in name="凤凰传奇" if "龙" not in name 阅读全文
posted @ 2025-05-25 11:45 大猫学编程 阅读(12) 评论(0) 推荐(0)
摘要: count=0while count<3: user=input(">>>") pwd=input("<<<") if user=="damao" and pwd=="123": print("欢迎登录") break else: print("<账号密码错误,请重新输入>") count=coun 阅读全文
posted @ 2025-05-25 10:43 大猫学编程 阅读(10) 评论(0) 推荐(0)
摘要: 只要见到continue,就表示要返回到while的条件判断处,不会执行continue后面的代码,一句话总结:终止当前循环,返回循环开始,重新进行判断 count = 0 while count < 10 : count = count + 1 print(count) continue prin 阅读全文
posted @ 2025-05-25 10:22 大猫学编程 阅读(61) 评论(0) 推荐(0)
摘要: 死循环: while 1 == 1: print("ok") 约束循环: count = 0 while count < 6: print('ok') count = count + 1 print(123) count = 0 while count < 6: print(count) count 阅读全文
posted @ 2025-05-19 20:16 大猫学编程 阅读(9) 评论(0) 推荐(0)
摘要: if条件语句,一般来说用4个空格做代码块前缀,如下if语句的嵌套 if 1==1: if 2==2: print('欢迎进入学校') else: print('欢迎进入游乐园') else: print('end') 或者多次判断: """ inp = input('请输入网吧会员级别:') if 阅读全文
posted @ 2025-05-19 20:03 大猫学编程 阅读(15) 评论(0) 推荐(0)
摘要: #永远等待用户输入,知道用户输入值,就会将输入的值赋给n1,n1代指用户输入的内容 n1=input('请输入用户名') n2=input('请输入密码') print(n1) print(n2) #表示为单行注释""" 表示为多行注释 """ n1在这里为变量 c语言的额底层逻辑是:变量只是过程, 阅读全文
posted @ 2025-05-18 19:53 大猫学编程 阅读(25) 评论(0) 推荐(0)