day3 前奏

1.第1个c语言

编辑---编译----运行
python@ubuntu:~/Desktop/pythons06$ vim 01-第1个c语言.c
#include<stdio.h>
int  main(int argc,char ** argv)
{
    printf("hello world\n");
    return 0;
}

python@ubuntu:~/Desktop/pythons06$ gcc 01-第1个c语言.c 
python@ubuntu:~/Desktop/pythons06$ ls -a
.   01-第1个c语言.c  1-softlink.txt  2.txt  5.py   command
..  1-hardlink.txt   1.txt           4.py   a.out  test.sh


python@ubuntu:~/Desktop/pythons06$ ./a.out 
hello world

 

2.第1个Python程序

编辑编译---》直接运行
python@ubuntu:~/pythons06$ vim 02-第1个Python.py 
print("hello world")

python@ubuntu:~/pythons06$ python 02-第1个Python.py 
hello world

 

    

 

3.python2 和Python3,IPython

  推荐:ipython3

python@ubuntu:~/pythons06$ python3
Python 3.5.2 (default, Jul  5 2016, 12:43:10) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> exit()
python@ubuntu:~/pythons06$

 
python@ubuntu:~/pythons06$ python3 02-第1个Python.py 
hello world
python@ubuntu:~/pythons06$ 

 

#ipython
python@ubuntu:~/pythons06$ ipython
Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: exit


#ipython3
python@ubuntu:~/pythons06$ ipython3
Python 3.5.2 (default, Jul  5 2016, 12:43:10) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 

 

 

4.注释

  注释的作用

  • 通过用自己熟悉的语言,在程序中对某些代码进行标注说明,这就是注释的作用,能够大大增强程序的可读性
  • 100行代码 50行注释

 

   python2 识别中文

 #-*- coding:utf-8 -*-            在python的语法规范中推荐使用的方式:
 #coding=utf-8

 

posted @ 2017-11-12 20:30  venicid  阅读(136)  评论(0编辑  收藏  举报