python 入门 一

#!/usr/bin/python
# _*_ coding:utf-8 _*_

print "hello"
print 'hello'
print '''1
2
3
4
5'''
var_a="123"
print var_a
var_b=123
print var_b;

del var_b;
del var_a;

# can read and write
list_var=[1,2,3,4,5,"6","7","8",'9','''-----------------------------'''];
print list_var;
print list_var[1];
print list_var[1:5];
list_var[0]="11111111";
print list_var;
# only for read
tuple_var=(1,2,3,4,'5');
print tuple_var;
print tuple_var[0];

dist_var={1:"one",2:"two"};

print dist_var;
print dist_var.values()
print dist_var.keys();
print dist_var[1];

# + / * / ** // %
print 2**2 # 2^2
print 5//2  # 5/2=2(<-)......1
print 5%2  # 5/2=2.......1(<-)

# (==) (!=) (<>) (>) (<) (>=) (<=)

# = += -= /= //= %= **=
# & | ! <<   >>

# and not or

# in ont in

#is is not

print 1 in list_var;
if  1 not in list_var:
	print "NOT"

list_var=[1,2,3,4,5,6,7,8,9,10];
for x in list_var:
	print x;

if  1==1:
	print "1==1"
else:
	print "1!=1"

if  1<>1:
	print 1;
elif 1>1:
	print 2;
else:
	print 3;

if  1==1:
	if 2==2:
		if  3==3:
			if 4==4:
				print 4==4
			print 3==3
		print 2==2
	print 1==1


index=1;
while  True:
	index+=1;
	print index;
	if index==20:
		break;
	pass;


 

    原文作者:python入门
    原文地址: https://my.oschina.net/pirtt/blog/967954
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞