1.长整数(过长时以L结束)
>>>234423234223243L
2.
变量名
字母数字,下划线(不能以数字开头)
3.注销 #
4.打印
print 2*2; print(2*2)
字符串:print("hellopyhon")// print 'hellopython'
5.输入
x=input("x:") #默认标准表达式或者数字
raw_input() #整行输入,字符串
6.if
if 1==2 print' one equals two'
7.API导入
from 包 import 方法名 (from math import sqrt)
使用方式一:
import math
math.floor(32.9)
使用方式二:(cmath不能import)
from math import sqrt
sqrt(9)
8.类型转换
print ‘x=',int(sqrt(9))
9.
输出
多格式
print 'x=',x #会产生空格
换行 ;\ 连接 (\n产生换行)
print x;\
print y
print''' 123
456
789'''
123
456
789
print r'''dsdfdf
fsdfsd\
dfsdf'''
dsdfdf
fsdfsd\
dfsdf
print '''dsdfdf\
fsdfsd\
dfsdf'''
dsdfdffsdfsddfsdf
print '''dsdfdf\
fsdfsd\n\
dfsdf'''
dsdfdffsdfsd
dfsdf
10.字符串
‘’ “” ''' ''' #这三种都可以定义字符串
print '"hhh"'
"hhh"
11.
了解某个函数
help(raw_input)
12.格式化输出
print(format())
>>> print(format(12.23434),'6.3f')
('12.23434', '6.3f')
>>> print(format(12.23434,'6.3f'))
12.234
>>> print(format(12.23434,'6.9f'))
12.234340000
>>> print(format(12.23434,'6.0f'))
12
>>> print(format(12.23434,'9.2f'))
12.23
>>> print(format(12.23434,'3.3f'))
12.234
>>> print(format(0.3456,'.2%'))
34.56%
>>> print(format(0.3456,'3.1%'))
34.6%
>>> print(format(0.3456,'6.1%'))
34.6%