python基础
来源:互联网 发布:阿里云服务器登陆账号 编辑:程序博客网 时间:2024/05/19 16:07
51cto python基础视频:点击打开链接
1、python 输入输出
输出语句: print
输入语句: raw_input(2.7版本)/input(3.4版本)
例:
>>> print ("Hello world")
Hello world
>>> a=11
>>> a=a+1
>>> print a
12
>>> str =raw_input("ent:")
ent:hello word
>>> raw_input(str)
hello word
2、python 源码编辑编译执行
a.py 源码文件 可编辑 编译
b.pyc 字节码文件 提高加载速度 被其他文件引用
python -m py_compile test.py (生成pyc文件)
c.pyo 字节码文件 优化编译
python -O -m py_compile test.py (生成pyo文件)
3、语法:
连接符:\
例:
>>> str = "this is a\
this is b \
this is c"
>>> print str
this is a this is b this is c
引号:
单引号(') 双引号(") 三引号(''') 表示字符串常量
注:在字符串常量中直接引用"或者'
a.使用'时候,字符串不能以'开始或结束
b.使用"时候,字符串不能以"开始或结束
注释:"#"
代码组: 关键字和':'构成一个代码组
例:
>>> a=10
>>> if(a==10):
print a
10
>>>
转义字符:
\ 续行符
\x 16进制表示字符
\o 8进制表示字符
\' 单引号
\" 双引号
\n 换行符
\r 回车
算数运算符:
+ - * / %
**(20**2=400)
// (9//2=4)舍去小数点后面值 除数不能为0
比较运算符;
== != > < >= <=
逻辑运算符:
and or not
- Python基础
- Python基础
- Python基础
- Python基础
- python基础
- Python基础
- python基础
- Python基础
- python 基础
- Python 基础
- python基础
- Python基础
- Python基础
- python基础
- Python基础
- python基础
- python基础
- Python基础
- PCL-1.7.2-AllInOne-msvc2013-win64+VS2013安装
- $.each 和$(selector).each()的区别
- webapp开发
- E/Minikin(32505): addFont failed to create font
- CentOS 7没有ifconfig命令
- python基础
- jQuery formValidator手册
- HDU6129 Just do it (找规律)
- 图卷积神经网络(Graph Convolutional Neural Network)
- iOS拍照之后图片在PC端粘贴后自动旋转90度
- 大学
- 关于windows虚拟桌面使用及录屏
- Geth搭建私有链
- 移动端触摸事件总结