Python——python了解

来源:互联网 发布:微表情测试软件 编辑:程序博客网 时间:2024/06/08 06:16

python

优点

简单、易学 、免费/开源 、自动内存管理 、可以移植 、解释性 、面向对象 、可扩展 、丰富的第三方库

缺点

速度慢、强制缩进、单行语句

[root@localhost ~]# python -V ##查看安装的python版本
Python 2.7.5
[root@localhost ~]# python ##交互式使用python

Python 2.7.5 (default, Feb 11 2014, 07:46:25) [GCC 4.8.2 20140120 (Red Hat 4.8.2-13)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> print "hello python"hello python>>> print hello python  File "<stdin>", line 1    print hello python                     ^SyntaxError: invalid syntax>>> a = 1>>> print a1>>> print "你好"你好>>> exit () ##退出

这里写图片描述

[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
[root@localhost mnt]# vim hello.sh ##编写一个shall脚本

#!/bin/bashecho hello

[root@localhost mnt]# chmod +x hello.sh
[root@localhost mnt]# ./hello.sh
hello
[root@localhost mnt]# cp hello.sh /bin/
[root@localhost mnt]# hello.sh
hello
这里写图片描述

[root@localhost mnt]# which python ##查看python位置
/usr/bin/python
[root@localhost mnt]# vim hello.py ##编写一个python脚本

#!/usr/bin/pythonprint "hello"

[root@localhost mnt]# python hello.py
hello
[root@localhost mnt]# chmod +x hello.py
[root@localhost mnt]# ./hello.py
hello
[root@localhost mnt]# cp hello.py /bin/
[root@localhost mnt]# hello.py
hello
这里写图片描述

[root@localhost mnt]# vim hello.py ##python写入中文方法

#!/usr/bin/python#!/ coding: utf-8print "hello"print "你好"

这里写图片描述
[root@localhost mnt]# python hello.py
hello
你好
这里写图片描述

[root@localhost mnt]# ipython ##python解释器的一种,进入python后可以用tab补齐
Python 2.7.5 (default, Feb 11 2014, 07:46:25)
Type “copyright”, “credits” or “license” for more information.

IPython 3.2.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]: hi = “hello”

In [2]: h
%%html %history hash help hi
%hist hasattr hello.py hex

In [2]: hi
Out[2]: ‘hello’
这里写图片描述

阅读全文
'); })();
1 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 油性笔写不出怎么办 指甲油涂不匀怎么办 口红涂不匀怎么办 防晒霜涂不匀怎么办 口红涂不匀有渣怎么办 宝宝不爱讲话怎么办 孩子没有礼貌怎么办 小孩的腿不直怎么办 小宝宝发烧怎么办 小宝宝长痱子怎么办 小宝宝不爱吃饭怎么办 小宝宝胀肚子怎么办 孩子三年级叛逆怎么办 小孩读书差怎么办 孩子早上磨蹭怎么办 孩子理解力差怎么办 不够细心怎么办 高中孩子厌学怎么办 不喜欢数学怎么办初中 幼儿内向怎么办 宝宝数学不好怎么办 脖子好黑怎么办 天生脖子黑怎么办 wps打不上字怎么办 苹果输入法数字怎么办 脚注序号中断怎么办 手机不能输入怎么办 宝宝37.2度怎么办 小朋友算术不好怎么办 算术不好找钱怎么办 大人算术不好怎么办? 《迷路了怎么办》教案 遇到危险怎么办ppt 突然天旋地转怎么办? 宝宝数手指怎么办 读书时添字漏字怎么办 错别字多怎么办 中考写错字怎么办 孩孑字写不好怎么办 孩子写字马虎怎么办 初中生错别字多怎么办