一、HelloWorld
#!/usr/bin/env python
#-*- coding:utf-8 -*-
print("HelloWorld!")
二、用户交互
#!/usr/bin/env python#_*_coding:utf-8_*_name = input("What is your name?")print("Hello " name )
输入密码时,如果想要不可见,需要利用getpass 模块中的 getpass方法,即:import getpass
# 将用户输入的内容赋值给 name 变量pwd = getpass.getpass("请输入密码:")  # 打印输入的内容print(pwd)#!/usr/bin/env python# -*- coding: utf-8 -*-name = "emily"print "i am %s " % name  #输出: i am emily#!/usr/bin/env python  # -*- coding: utf-8 -*-a = 30
count = 0
while count <3:
b = int(input("a:"))
if a == b:
print("yes")
break
elif a>b:
print("small")
else:
print("big")
count +=1
else:
print ("you have tried too many times..fuck off")
for i in range(10):
print(‘------‘,i)
for j in range(10):
print(j)
if j>5:
break
原文:http://www.cnblogs.com/yue427/p/6546896.html