python 例子1

python简单的交互式操作,实例

方法一:

#!/usr/bin/env python

#encoding:utf8

# Filename:interactive.py

name= raw_input("please input your name:")

passwd= raw_input("please input your passwd:")

count = 0

temp = 0

if name == ‘liu‘:

if passwd ==  ‘123‘:

print ‘welcome login!‘

else:

for i in range(4):

count += i

if passwd == ‘123‘:

print ‘welcome login‘

break

if ( count == 3 ):

print "you passwd locked!"

else:

passwd= raw_input("please reset input your passwd:")

elif passwd == ‘123‘:

print ‘true‘,passwd

for x in range(4):

temp += x

print ‘varlue:‘,temp

if name == ‘liu‘:

print ‘welcome login‘

break

if ( temp == 3 ):

print "you name locked"

break

else:

name= str(raw_input("please reset input your name:"))

else:

print ‘name,passwd error!:‘

#####################################################################################

方法二:

#!/usr/bin/python

# Filename:interactive_1.py

i = 1

while 1:

Name = raw_input("please input your name:")

Email = raw_input("please input your email:")

QQ = int(raw_input("please input your qq:"))

s2 = "{Name:[Email,QQ]}"

s3 = eval(s2)

#   if s3.has_key(Name):

s3 =  dict(s3.items() + s3.items())

print i

i += 1

if i > 3:

break

#s3(s3.items()) += s3(s3.items())

#   else:

#       raw_input("First please input your information! Enter")

时间: 2024-10-08 03:35:59

python 例子1的相关文章

python例子-线程和队列

#!/usr/bin/python #coding:utf-8 import threading import time import Queue import random #多线程理解 def print_time(threadName,delay,counter): while counter: time.sleep(delay) print "%s:%s\n" %(threadName,time.ctime(time.time())) counter -=1 def main(

python例子-Django常用命令

1.新建一个Django项目: django-admin startproject project-name or django-admin.py startproject project-name 2.新建项目木下的一个子app:(是到生成的项目文件夹下) python manage.py startapp app-name or django-admin.py startapp app-name 3.同步数据库: python manage.py syncdb 注意:Django 1.7.1

python例子-关于时间time模块

2015年10月17日09:28:42 python-time 访问网站如果不想要缓存的就 在后面加 ?t=123 如果网站遭到攻击应该怎么办,做流量清洗,分析包,正确的就放过,否则就抛弃掉. 如果攻击的站站带宽满了,就看看是否让运营商帮忙做清洗. 一般网站都有所CDN,否则扛不住. CDN: http://baike.baidu.com/link?url=XB3KAt8HGcKeiwEKvq0ZN59YxXohdEM1a_B2AARlUDc4uFHkwfRTp3VgHhhQvJkLZDshvw

python例子-urllib,urllib2练习题合集.

#!/usr/bin/python #coding:utf-8 import time import urllib import urllib2 from bs4 import BeautifulSoup import re import cookielib def main0(): unix_timenow = int(time.time()) print '当前时间:%d' % unix_timenow timenow = time.strftime('%Y-%m-%d %H:%M:%S',

python例子-开始一个Django项目

一.创建项目: django-admin startproject mysite 二.到该目录下,创建app: python manage.py startapp learn # learn 是一个app的名称 并将app添加到mysite/mysite/settings.py 中: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.co

第一个自己编写的面向对象的Python例子

class Student(object):     #定义一个类,括号内容表示继承自那个类,不知道继承自哪个类就用object类#     def __init__(self,name,score):#__init__是一个初始化的方法,定义的参数,属性可以在全局中调用,这里的name,score是一个全局参数#         self.name=name               self.score=score         self.tt=name+'的分数是'+str(score

python例子-PyQuery抓取信息.

#!/usr/bin/python #coding:utf-8 from pyquery import PyQuery import re # 抓取:http://www.stylebop.com/cn/product_details.php?id=606526&special=sale # 获得 产品名 品牌 价格 size 图片(大图) def main(): pqhtml = PyQuery(url = 'http://www.stylebop.com/cn/product_details

几个python例子

count = 0 ile count < 101: temp = 0 temp = count % 2 if temp == 0: print(count) else: pass count = count + 1 count = 0 while count < 10: if count == 7: count = count + 1 continue print(count) count = count + 1 #!/usr/bin/env python # -*- coding:utf8

Python 例子

def multiply(x):         return (x*x) def add(x):         return (x+x) funcs = [multiply, add] for i in range(5):     value = map(lambda x: x(i), funcs)     print(list(value))