首页 > 其他分享 >第三章 1 变量

第三章 1 变量

时间:2022-08-16 15:22:48浏览次数:53  
标签:第三章 变量 python idea better than name

第三章 1 变量

1、查看变量类型的python内置函数是?
type()

2、查看变量内存地址的python内置函数是?
id()

3、python变量命名规范?
1、使用字母、数字、下划线来命名,但不能以数字开头
2、系统定义的关键字,不能作为变量使用
3、除了下划线,不能使用其他符号
4、python变量名区分大小写
5、python使用小驼峰法,如is_peison\first_name
其他要求
1、描述越精准越好,最好能一看就能看出来类型
2、变量名尽量短,但不要太短
3、合理使用变量,要控制变量数量
4、定义临时变量增加可读性
5、删除掉没用的变量

4、关于python内存管理 ,下列说法错误的是()
变量不必事先声明
变量无须先创建和赋值而可以直接使用
变量无须指定类型
可以使用del释放资源
2是错的。。。。python中,变量可以不用事先声明,可以事先不用赋值
如:name = None
print(name)


import this
print(this)

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
漂亮总比难看好。
显性比隐性好。
简单比复杂好。
复杂比复杂好。
平的比嵌套的好。
疏比密好。
可读性。
特殊情况并不特别到足以打破规则。
尽管实用性胜过纯洁。
错误不应该悄无声息地过去。
除非显式地沉默。
面对模棱两可,拒绝猜测的诱惑。
应该有一种——最好只有一种——明显的方法来做这件事。
除非你是荷兰人,否则这种方式一开始可能并不明显。
现在做总比不做好。
虽然永远不做总是比现在好。
如果实现很难解释,那就不是一个好主意。
如果实现易于解释,那么它可能是个好主意。
名称空间是一个很棒的主意——让我们做更多这样的事情吧!

标签:第三章,变量,python,idea,better,than,name
From: https://www.cnblogs.com/leeyong49/p/16591662.html

相关文章