1、基本语法:print输出
print("Hellen");
#!/usr/bin/python
# -*- coding: UTF-8 -*-
x="a"
y="b"
# 换行输出
print x
print y
print '---------'
# 不换行输出
print x,
print y,
# 不换行输出
print x,y
以上实例执行结果为:
a
b
---------
a b a b
2、Python保留字符---关键字只包含小写
and | exec | not |
assert | finally | or |
break | for | pass |
class | from | |
continue | global | raise |
def | if | return |
del | import | try |
elif | in | while |
else | is | with |
except | lambda | yield |
3、行与缩进
Python 缩进的空白数量是可变的,但是所有代码块语句必须包含相同的缩进空白数量。
4、多行语音
Python中可以使用 \ 换行。
5、Python 中可以使用 引号(') 、双引号("")、三引('''或者""")号来表示字符串。
比如:
word = 'word'
sentence = "这是一个句子。"
paragraph = """这是一个段落。"""
6、Python空行 也是程序代码的一部分