Python——为函数添加注释

给自己写的函数添加注释,并在调用自动补全时可以显示提示:

在函数定义下面使用'''进行注释

def read_json_file(file_name):
	'''
		从tweets中提取ID,并组成集合返回
	'''
	with open(file_name, "r", errors="ignore") as f:
		tweet_id_set = set()
		for line in f:
			json_obj = json.loads(line.strip())
			tweetid = json_obj["tweetId"]
			tweet_id_set.add(tweetid)
		return tweet_id_set
发布了52 篇原创文章 · 获赞 21 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/zhr1030635594/article/details/102885922
今日推荐