潇洒瓶邪

2022年3月7日

python基础3

摘要: 1.循环 Python的循环有两种,一种是for...in循环,依次把list或tuple中的每个元素迭代出来,看例子: names = ['Michael', 'Bob', 'Tracy'] for name in names: print(name) 执行这段代码,会依次打印names的每一个元 阅读全文

posted @ 2022-03-07 17:20 潇洒的姜伯约 阅读(44) 评论(0) 推荐(0)

python基础2--

摘要: 因为input()返回的数据类型是str,str不能直接和整数比较,必须先把str转换成整数。Python提供了int()函数来完成这件事情: s = input('birth: ') birth = int(s) if birth < 2000: print('00前') else: print( 阅读全文

posted @ 2022-03-07 16:12 潇洒的姜伯约 阅读(34) 评论(0) 推荐(0)

python基础1

摘要: 1.Python的语法比较简单,采用缩进方式,写出来的代码就像下面的样子: # print absolute value of an integer: a = 100 if a >= 0: print(a) else: print(-a) 2.Python程序是大小写敏感的,如果写错了大小写,程序会 阅读全文

posted @ 2022-03-07 15:39 潇洒的姜伯约 阅读(45) 评论(0) 推荐(0)

导航