# -*- 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()

  

Python学习日记之练习代码的更多相关文章

  1. Python 学习日记(第三周)

    知识回顾 在上一周的学习里,我学习了一些学习Python的基础知识下面先简短的回顾一些: 1Python的版本和和安装 Python的版本主要有2.x和3.x两个版本这两个版本在语法等方面有一定的区别 ...

  2. Python学习日记 --day2

    Python学习日记 --day2 1.格式化输出:% s d  (%为占位符 s为字符串类型 d为数字类型) name = input('请输入姓名') age = int(input('请输入年龄 ...

  3. python学习日记(基础数据类型及其方法01)

    数字 int 主要是用于计算的,常用的方法有一种 #既十进制数值用二进制表示时,最少使用的位数i = 3#3的ASCII为:0000 0011,即两位 s = i.bit_length() print ...

  4. Python学习日记(一):拜见小主——Python

    近日学习Python,特将学习过程及一点心得记录于此. 由于之前做过一个Java爬虫的项目,虽然很长时间没有碰过爬虫,但是小郭同学有一颗不死的爬虫心,哈哈.最近在互联网上找一些电影的时候,有很多电影只 ...

  5. Python学习日记(二十八) hashlib模块、configparse模块、logging模块

    hashlib模块 主要提供字符加密算法功能,如md5.sha1.sha224.sha512.sha384等,这里的加密算法称为摘要算法.什么是摘要算法?它又称为哈希算法.散列算法,它通过一个函数把任 ...

  6. Python 学习日记(第二周)

    从这周开始我就正式学习Python 语言了.以后每周都会有一篇有关于学习Python的见闻与大家分享! Python的安装 学习的第一步首先要有一个运行的环境.所以接下来介绍一下安装的步骤. 通过Py ...

  7. 从CentOS安装完成到生成词云python学习日记

    欢迎访问我的个人博客:原文链接 前言 人生苦短,我用python.学习python怎么能不搞一下词云呢是不是(ง •̀_•́)ง 于是便有了这篇边实践边记录的笔记. 环境:VMware 12pro + ...

  8. python学习日记(常用模块)

    模块概念 什么是模块 常见的场景:一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 但其实import加载的模块分为四个通用类别: 1 使用python编写的代 ...

  9. python学习日记(函数--装饰器)

    楔子 前提,我有一段代码(一个函数). import time def run_time(): time.sleep(0.1) print('我曾踏足山巅') 需求1:现在,我想计算这段代码的运行时间 ...

随机推荐

  1. 多路转接模型之poll

    poll系统调用和select类似.也是在指定时间内轮询一定数量的文件描写叙述符,以測试当中是否有就绪者.poll和select效率差点儿相同,仅仅是其使用接口相对简单些,poll不在局限于1024个 ...

  2. 关于使用data()获取自定义属性出现undefined的说明

    这应该是这个函数的一个bug,没有考虑到驼峰式的写法,当我写成驼峰式,即是有大小写的变量时就会出现没有定义的情况. 今天写个交互,需要用到自定义属性,因为这个自定义属性是当作字段用的,就直接用了字段名 ...

  3. 网上Unused Index Script 脚本的问题

    曾经使用过网上下载的脚本查询没有使用过的Index比方SQL SERVER – 2008 – Unused Index Script – Download,事实上如今看起来这个脚本是有一些问题. 脚本 ...

  4. LVS 负载均衡 (VS/DR模式 与 VS/TUN 模式)

    一.VS/DR模式 ①.客户端将请求发往前端的负载均衡器,请求报文源地址是CIP,目标地址为VIP. ②.负载均衡器收到报文后,发现请求的是在规则里面存在的地址,那么它将目标MAC改为了RIP的MAC ...

  5. GSON学习笔记之初识GSON

    引用"JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,採用全然独立于语言的文本格式.为Web应用开发提供了一种理想的数据交换格式. " ...

  6. javascript返回顶端源代码

    <div style="display:none" id="goTopBtn"><img src="http://www.unity ...

  7. PCCs系数

    package ai; public class pccs { public static void main(String[] args) { double same[][]=new double[ ...

  8. redux 调试工具

    首先安装谷歌插件: redux-devtools 然后项目中安装插件:redux-devtools-extension 最后在创建 store 的时候进行配置: import { composeWit ...

  9. 8148和8127中的ezsdk和dvrsdk

    http://www.dajudeng.com/d2012081009b8a9d5de87101f69f31952c.html

  10. 一张图轻松记住PHP的*类*以及private和protected的区别

    上图概要的说了下php类的特性,类的方法同属性类似. 图中B类继承自A类,B是A的子类,$x和$y都是B的实例化对象. 1. 原型引用:[A::    . B::   ],仅限public stati ...