# -*- coding:utf-8 -*-
number = 23
test=True
while test:
guess=int(raw_input('输入数字'))
if guess==number:
print 'g=n'
elif guess>number:
print 'g>n'
else:
print "g<n"
# -*- coding:utf-8 -*-
while True:
s=raw_input('输入任意字符')
if s=='q':
break
print '总长度为',len(s)
print '结束'
# -*- coding:utf-8 -*-
def test():
global y,o
y=o+y
o=y-o
y=y-o
y=5
o=7
test()
print y,o
# -*- coding:utf-8 -*-
booklide=['1','2','3']
for item in booklide:
print item,
booklide.append('4')
print booklide
del booklide[0]
print booklide
zoo=('91','82','73')
print zoo
print len(zoo)
print zoo[2][1]
print '%s'%(zoo[1][1])
# -*- coding:utf-8 -*-
import os
import time
# 需要备份目录
source=['e:\\ppt']
# 存放目录
target_dir="E:\\"
target = target_dir + time.strftime('%Y%m%d%H%M%S')+'.zip'
print target
#rar_command='rar a %s %s'%(target,''.join(source))
rar_command = 'E:\winrar\WinRAR.exe a %s %s' % (target,' '.join(source))
print rar_command
if os.system(rar_command) == 0:
print '备份成功',target
else:
print '备份失败;dfsfgfdfrrggrr'
# -*- coding:utf-8 -*-
class school:
def __init__(self,name,age):
self.name=name
self.age=age
def tell(self):
print '%s %d'%(self.name,self.age),
class teacher(school):
def __init__(self,name,age,a):
school.__init__(self,name,age)
self.a=a
def tell(self):
school.tell(self)
print '%d'%(self.a)
t=teacher('姓名',20,3000)
t.tell()
# -*- coding:utf-8 -*-
test='''\
这是一个测试
测试文件读写
'''
f=file('test.txt','w')
f.write(test)
f.close()
f=file('test.txt')
while True:
line=f.readline()
if len(line)==0:
break
print line,
f.close()
# -*- coding:utf-8 -*-
import urllib
url='http://www.163.com'
html=urllib.urlopen(url)
#print html.read()
content=html.read().decode('gbk','ignore').encode('utf-8')
print content
# -*- coding:utf-8 -*-
import os
import fnmatch
import re
ins="E:\\学习资料\\python"
path=unicode(ins,'utf-8')
def finds(path,fnexp):
for root,path,files in os.walk(path):
for filename in fnmatch.filter(files, fnexp):
yield os.path.join(root,filename)
for filename in finds(path, "*.html"):
files = open('key.txt', 'a')
alltext = open(filename).read()
p1 = r'视频播放密码为:.*?(?=<)'
pattern1 = re.compile(p1)
matcher1 = re.search(pattern1, alltext)
files.write(matcher1.group(0)+'\n')
files.close()