随笔分类 -  python

摘要: 阅读全文
posted @ 2023-06-07 11:37 tigergaonotes 阅读(8) 评论(0) 推荐(0) 编辑
摘要:Python中的 if __name__ == '__main__' 是什么意思? 对于Python初学者,在看到这个if __name__ == '__main__' 的判断,并且下面还有代码语句,看了其他地方的说明,还是没搞明白是什么意思, 在看到这句话时,终于醍醐灌顶,就是下面这句话: __n 阅读全文
posted @ 2022-01-27 23:13 tigergaonotes 阅读(49) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
posted @ 2022-01-27 22:04 tigergaonotes 阅读(35) 评论(0) 推荐(0) 编辑
摘要:给定一个列表,然后给一个目标值,列表中两数求和等于目标值,要求输出列表两数的下界 如 list = [1,2,3,4,6,7,8] num=10 #!/usr/bin/python #coding=utf-8 list = [1,2,3,4,6,7,8] num=10 for m in range( 阅读全文
posted @ 2022-01-20 22:24 tigergaonotes 阅读(95) 评论(0) 推荐(0) 编辑
摘要:py调用shell 阅读全文
posted @ 2021-09-18 21:51 tigergaonotes 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-05-05 17:21 tigergaonotes 阅读(36) 评论(0) 推荐(0) 编辑
摘要:#/usr/bin/python #coding=utf-8 class Car(): def __init__(self,name,year): self.name = name self.year = year def model(self): vv = f"my car is {self.na 阅读全文
posted @ 2021-02-01 21:22 tigergaonotes 阅读(47) 评论(0) 推荐(0) 编辑
摘要:原因:pip源超时了,安装不上 pip install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技 阅读全文
posted @ 2021-01-25 21:13 tigergaonotes 阅读(186) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import json numbers = [2,3,4,7,11,13] filename = 'numbers.json' with open(filename,'w') as f: json.dump(numb 阅读全文
posted @ 2021-01-20 22:33 tigergaonotes 阅读(113) 评论(0) 推荐(0) 编辑
摘要:使用 try-except代码块来处理异常。 阅读全文
posted @ 2021-01-17 21:03 tigergaonotes 阅读(56) 评论(0) 推荐(0) 编辑
摘要:人生苦短,我用Python 博客园精华区01-15 23:46 (一)认识Python Python背景介绍 Python的格言: Life is short,use python. (人生苦短,我用Python。) 由Guido van Rossum于1989年圣诞节为打发无聊时间,而开发的一个新 阅读全文
posted @ 2021-01-16 22:27 tigergaonotes 阅读(190) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 lst = ['hongkong','xiantyk','chinat','guangdong','z'] lst2 = [] lst3 = [] lst4 = [] def get_num(): for i in 阅读全文
posted @ 2021-01-13 22:13 tigergaonotes 阅读(522) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 class Car: """一次模拟汽车的简单尝试""" def __init__(self,make,model,year): """初始化汽车的属性""" self.make = make self.model 阅读全文
posted @ 2021-01-11 22:07 tigergaonotes 阅读(58) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 class Dog: """一次模拟小狗的简单尝试""" def __init__(self,name,age): """初始化属性名字和年龄""" self.name = name self.age = age 阅读全文
posted @ 2021-01-09 22:09 tigergaonotes 阅读(55) 评论(0) 推荐(0) 编辑
摘要:导入整个模块: import 模块名 导入特定函数: from module_name import function_name 通过逗号可以分割函数名,如果需要导入多个则 from a import b,c,d,e View Code 阅读全文
posted @ 2021-01-09 21:38 tigergaonotes 阅读(120) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def make_pizza(*toppings): print("\nmaking a pizza with the following toppings:") for topping in toppings: 阅读全文
posted @ 2021-01-09 21:24 tigergaonotes 阅读(160) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def describe_pet(type,name): print(f"i have a {type};") print(f"my {type}'s name is {name}!") describe_pet( 阅读全文
posted @ 2021-01-05 21:37 tigergaonotes 阅读(89) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def describe_pet(type,name): print(f"i have a {type};") print(f"my {type}'s name is {name}!") describe_pet( 阅读全文
posted @ 2021-01-05 21:34 tigergaonotes 阅读(81) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def user(username): """显示用户名""" print(f"hello,{username.title()}!") user("tiger") 阅读全文
posted @ 2021-01-05 21:28 tigergaonotes 阅读(45) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 a = 1 while a <= 6: print(a) a = a + 1 #!/usr/bin/python #coding=utf-8 #好好学习,天天向上 a = 1 while a <= 6: a = a 阅读全文
posted @ 2021-01-04 22:04 tigergaonotes 阅读(65) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示