1.新建demo.py   里面写好print "hello world!"

2.linux原装python,ctrl+shift+T调出终端,进入demo.py目录,输入print "hello world!"

3.python hello world 开始

4.当输入 中文的时候会报错,File "demo2.py", line 2

SyntaxError: Non-ASCII character '\xe4' in file demo2.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

5.设置UTF-8解决编码问题

#!/usr/bin/python

# -*- coding: UTF-8 -*-

print "你好,世界";

6.ide下载安装   

pycharm

可参考https://blog.csdn.net/incloud_anke/article/details/53508310

**:可参考  https://blog.csdn.net/u014044812/article/details/78727496

7.成功运行python ide

python hello world 开始


8.python中单行注释采用 # 开头。python 中多行注释使用三个单引号(''')或三个双引号(""")。

9.缩进:

学习 Python 与其他语言最大的区别就是,Python 的代码块不使用大括号 {} 来控制类,函数以及其他逻辑判断。python 最具特色的就是用缩进来写。缩进的空白数量是可变的,但是所有代码块语句必须包含相同的缩进空白数量,这个必须严格执行

10.

#python3raw_inputinput进行了整合,只有input难过

#python3写法
input("按下 enter 键退出,其他任意键显示...\n")

#python2写法
#raw_input("按下 enter 键退出,其他任意键显示...\n")

11.Python可以在同一行中使用多条语句,语句之间使用分号(;)分割

12.print 默认输出是换行的,如果要实现不换行需要在变量末尾加上逗号 ,


本文案例来源于http://www.runoob.com/python/python-100-examples.html,做一下记录。

相关文章: