python基本笔记

#!/usr/bin/python

#!/usr/bin/env python

print 'hello world!'



#create .pyc file

import py_compile

py_compile.compile("hello.py")


#create .pyo file

python -O -m py_compile hello.py


a=raw_input()

a=int(raw_input("please input num1"))




coding:UTF-8

-*-coding:UTF-8-*-

coding:GB2312

-*-coding:GB2312-*-


from future import division


type()

int()

long()

float()

complex()

tuple()

str()

hex()

oct()

chr()

ord()


lambda

abs()

max()

min()

len()

divmod()

pow()

round()


callable()

isinstance()

cmp()

range()

xrange()


str.capitalize()

str.find()

str.replace()

str.split()

str.upper()

str.isalpha()

str.isdigit()

str.rstrip()



import string



filter()

zip()

map()

reduce()


import sys

sys.platform


from imp import reload

reload(script)

exec(open('module.py')read())


import math

math.pi

math.sqrt()


import random

random.random()

random.choice([a,b,c,d])


import re

a=re.match()    

a.group()


pop

remove

insert

sort

reverse

open()

read()

write()

close()

seek()

iterator()


你可能感兴趣的:(python基本笔记)