'''
python保留字即关键字,我们不能把它们用作任何标识符名称。Python 的标准库提供了一个 keyword 模块,可以输出当前版本的所有关键字:
'''
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

#单行注释以 # 开头
#the 1th comment
print("hello, python!")

#多行注释可以用多个 # 号,还有 ''' 和 """
'''
the 2th comment
the 3th comment
'''

"""
the 4th comment
the 5th comment
"""

'''
 python最具特色的就是使用缩进来表示代码块,不需要使用大括号({})。
缩进的空格数是可变的,但是同一个代码块的语句必须包含相同的缩进空格数
'''
if True:
    print("True")
    print("True end")
else:
    print("False")
    print("False end")

#缩进不一致,执行后会出现类似以下错误:
'''this will cause indentation error:IndentationError: unindent does not match any outer indentation level'''    
 
 
#通常是一行写完一条语句,但如果语句很长,我们可以使用反斜杠(\)来实现多行语句
item1 = 1
item2 = 2
item3 = 3
total = item1 + \
        item2 + \
        item3
        
print(total)

#在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\)
total = {item1 +
        item2 +
        item3}
print(total)

'''
python中单引号和双引号使用完全相同。
使用三引号('''或""")可以指定一个多行字符串。
转义符 '\'
自然字符串, 通过在字符串前加r或R。 如 r"this is a line with \n" 则\n会显示,并不是换行。
python允许处理unicode字符串,加前缀u或U, 如 u"this is an unicode string"。
字符串是不可变的。
"""
print(r"this is a line with \n")
print(u"this id a unicode string")

#函数之间或类的方法之间用空行分隔,表示一段新的代码的开始
#按回车键后就会等待用户输入
input("\n\n请输入,按下enter键后退出。\n")

#Python可以在同一行中使用多条语句,语句之间使用分号(;)分割
import sys; x = "runoob"; sys.stdout.write(x + '\n');

#print 默认输出是换行的,如果要实现不换行需要在变量末尾加上 end=""
print('不换行a', end = " ")
print("不换行b", end = " ")

'''
缩进相同的一组语句构成一个代码块,我们称之代码组。
像if、while、def和class这样的复合语句,首行以关键字开始,以冒号( : )结束,该行之后的一行或多行代码构成代码组。
我们将首行及后面的代码组称为一个子句(clause)
'''
import sys
for i in sys.argv:
    print(i)
print("\n python路径为", sys.path)

"""
在 python 用 import 或者 from...import 来导入相应的模块。
将整个模块(somemodule)导入,格式为: import somemodule
从某个模块中导入某个函数,格式为: from somemodule import somefunction
从某个模块中导入多个函数,格式为: from somemodule import firstfunc, secondfunc, thirdfunc
将某个模块中的全部函数导入,格式为: from somemodule import *
"""
from sys import path
print('path:', path)

最新文章

  1. 基于改进人工蜂群算法的K均值聚类算法(附MATLAB版源代码)
  2. for_each()的返回值
  3. yii CDbCriteria 类的总结
  4. SquashFs工具制作
  5. POJ-1151 Atlantis 矩形面积并
  6. JSP通过SmartUpload上传文件实例
  7. [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
  8. TagHelper的一些个人学习体会(发现了微软官方文档的一个错误)
  9. ant基础[转]
  10. PHP实现用户注册并保存数据到文件
  11. api接口的记录
  12. Nodejs全局/缓存路径配置
  13. windows下python操作mysql模块安装
  14. 错误RSA host key for [ip address] has changed and you have requested strict checking.
  15. vs2015智能提示英文改为中文
  16. java安装1.8和1.7,报错:Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVers
  17. iOS.Info.plist
  18. 在Linux上实现SVN用户密码自助修改
  19. 毕业回馈-89c52之最小系统
  20. 区块链blockchina简述

热门文章

  1. object hook实现禁止创建文件
  2. ftp mybatis
  3. JDK自带监控工具 jps、jinfo、jstat、jmap、jconsole
  4. python读取文件下的所有文档
  5. 打开eclipse中文件所在文件夹
  6. python判断文件是否存在目录中
  7. 经典图算法Java代码实践:BFS,DFS以及几种最短路径算法
  8. Atitit. camel分词器 分词引擎 camel拆分 的实现设计
  9. [ci]项目规划-后续
  10. C语言基础(20)-文件操作(fopen,getc,fclose)