摘要:
封装 class Turtle: head = 1 eyes = 2 leg = 4 shell = True def crawl(self): print("人们总抱怨我动作慢吞吞的,殊不知如不积跬步,无以至千里的道理。") def run(self): print("虽然我行动很慢,但如果遇到危 阅读全文
posted @ 2022-08-05 09:11
tuyin
阅读(36)
评论(0)
推荐(0)
摘要:
求一个数的阶乘 # 迭代方法实现 def factIter(n): result = n for i in range(1, n): result *= i return result print(factIter(10)) # 递归方法实现 def funC(n): if n == 1: retu 阅读全文
posted @ 2022-08-05 08:51
tuyin
阅读(29)
评论(0)
推荐(0)
摘要:
创建和调用函数 # I Love You # I Love You # I Love You def myfunc(): for i in range(3): print("I Love You") myfunc() 函数的参数 # I Love python # I Love python # I 阅读全文
posted @ 2022-08-05 08:48
tuyin
阅读(58)
评论(0)
推荐(0)
摘要:
创建集合 # 集合,无序 # 创建集合 # {'Love', 'Python'} print({"Love", "Python"}) # {'o', 'h', 't', 'n', 'P', 'y'} print({s for s in "Python"}) # {'o', 'h', 't', 'n' 阅读全文
posted @ 2022-08-05 00:07
tuyin
阅读(27)
评论(0)
推荐(0)
摘要:
x = {"卢布", "关羽"} print(type(x)) y = {"卢布":"小布布", "关羽":"小鱼鱼"} y["刘备"] = "小贝贝" print(y) print(y["卢布"]) 创建字典的方式 a = {'卢布': '小布布', '关羽': '小鱼鱼', '刘备': '小贝贝 阅读全文
posted @ 2022-08-05 00:05
tuyin
阅读(115)
评论(0)
推荐(0)
摘要:
sorted方法 t = ["FishC", "Apple", "Book", "Banana", "Pen"] # sorted方法只是比较首个字母的ASCALL值,如果第一个字母相同就比较第二个字母 # ['Apple', 'Banana', 'Book', 'FishC', 'Pen'] s 阅读全文
posted @ 2022-08-05 00:01
tuyin
阅读(42)
评论(0)
推荐(0)

浙公网安备 33010602011771号