设为首页 加入收藏

TOP

python 关键词记录
2018-12-14 02:56:51 】 浏览:23
Tags:python 关键词 记录

1, global 当某个变量在函数内被声明为global之后,在函数内的修改也会对函数之外的引用产生作用。

#-*-  coding:utf-8 -*-
#global 作用方式
def count(prise):
	global old_prise
	
	new_prise = old_prise+1
	print "old_prise is %d" % old_prise
	old_prise = 20 
	print "new_prise is %d" %new_prise
	return new_prise

old_prise = 10
finally_prise = count(old_prise)
print " global old_prise is %d"%old_prise
print "finally_prise is %d" %finally_prise

2, pass

pass为空语句,与C/C++中的空语句类似

raw_input("Null>")
if Null !== 123
	assert#假如assert不存在则会报错
else:
	print "Null !== 123"

3, yield

yield

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python 中的类 下一篇Python对象

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目