# -*- 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. 程序猿是如何解决SQLServer占CPU100%的--马非码

    http://www.cnblogs.com/marvin/p/ASolutionForSQLServerCauseHighCPU.html

  2. Ionic3错误记录:navigation stack needs at least one root page

    BUG场景:在 ActionSheetController 使用modalCtrl.create 创建模态框时报如下错误 原代码片段 解决方式: 重新设置root page

  3. 微信小程序 wafer2框架摘要

    微信小程序 wafer2框架摘要 帮助文档:https://github.com/tencentyun/wafer2-startup/wiki 使用了knex.js进行数据库交互,使用了koa.js进 ...

  4. ORACLE取周、月、季、年的開始时间和结束时间

     1           取周的開始时间和结束时间 取周的開始时间.以星期一为開始. SQL>SELECT TRUNC(TO_DATE('2013-11-25 10:31:11','YYYY ...

  5. hdu 3006 The Number of set(思维+壮压DP)

    The Number of set Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. Python3.4 12306 2015年3月验证码识别

    import ssl import json from PIL import Image import requests import re import urllib.request as urll ...

  7. HDU 1047 Integer Inquiry 大数相加 string解法

    本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...

  8. HttpUtils 发送http请求工具类

    import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URISyntaxEx ...

  9. (六)Java 基本数据类型

    Java 基本数据类型 变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间. 内存管理系统根据变量的类型为变量分配存储空间,分配的空间只能用来储存该类型数据. 因此,通过定义不 ...

  10. jar包和动态链接库

    1 jar包更接近于动态链接库 java在编译的时候,尽管import了其它的jar包,但是它并没有将其它jar包中的源码拷贝到自己的class文件中,它只是使用了jar包中的名字. 而在执行的时候, ...