首页 / PYTHON / python 学习笔记(4)
python 学习笔记(4)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python 学习笔记(4),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1734字,纯文字阅读大概需要3分钟。
内容图文
- Expression in parentheses
()
, square bracket[]
, and curly braces{}
can span multiple lines. - A backslash (
\
) at the end of the line denotes continuation to the next line. This is an old rule and is NOT recommended as it is error-prone.
A compound statement, such as def
(function definition), while
-loop, begins with a header line terminated with a colon (:
); followed by the indented body block. Python does not specify how much indentation to use, but all statements of the body block must start at the same distance from the right margin.
In Python, 0
, None
and empty value (such as empty string ‘‘
, ""
, empty list []
, empty tuple ()
, empty dictionary {}
) are treated as False
; anything else are treated as True
. Booleans can also act as integers in arithmetic operations with 1
for True
and 0
for False
.
Python is dynamic typed. It associates types with objects, instead of variables. That is, a variable does not have a fixed type and can be assigned an object of any type. A variable simply provides a reference to an object.
You do not need to declare a variable. A variable is created automatically when a value is first assigned, which link the variable to the object. You can use built-in function type(var_name)
to get the object type referenced by a variable.
Python does not support increment (++
) and decrement (--
) operators (as in C/C++/Java). You need to use i = i + 1
or i += 1
for increment.
import module_name
statement: To refer to an attribute, use module_name.attr_name
.
from module_name import attr_name
statement: You can use attr_name
directly without the module_name
.
from module_name import *
statement: Import all attributes of the module.
原文:http://www.cnblogs.com/wintor12/p/3950640.html
内容总结
以上是互联网集市为您收集整理的python 学习笔记(4)全部内容,希望文章能够帮你解决python 学习笔记(4)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。