# -*- 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. C#写的NoSQL开源项目/系统(系列)

    http://www.cnblogs.com/unruledboy/archive/2013/01/07/CSharpNoSQL.html 闲扯 好久没写开源项目了,也没写对新开源项目的介绍,今晚看了 ...

  2. golang 跨平台编译——go 在windows上编译Linux平台的程序(Cross Compilation from Windows to Linux/Ubuntu)

    Go Cross Compilation from Windows to Linux/Ubuntu I have GO 1.7 installed on my Windows 10. I create ...

  3. cocos2d-x+lua开发模式下编辑器的选择

    原本打算直接用CocosIDE的,毕竟是官方出品,并且支持Android远程调试,windows下的调试也非常方便,调试的信息也非常全,智能提示也不错.好了,一切看上去非常完美,可是它有一个致命缺陷, ...

  4. JAVA进阶-网络编程

    >通过套接字连接server Socket指代套接字 >读取随意站点的首页 --------- /** * @author Lean @date:2014-10-9 */ public c ...

  5. Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip 树形压位DP

      题目链接:http://codeforces.com/contest/766/problem/E Examples input 3 1 2 3 1 2 2 3 out 10 题意: 给你一棵n个点 ...

  6. Python获得文件时间戳 异常访问监控 邮件定时提醒

    Python获得文件时间戳  异常访问监控 邮件定时提醒

  7. poj 1459 多源汇网络流 ISAP

    题意: 给n个点,m条边,有np个源点,nc个汇点,求最大流 思路: 超级源点把全部源点连起来.边权是该源点的最大同意值: 全部汇点和超级汇点连接起来,边权是该汇点的最大同意值. 跑最大流 code: ...

  8. ROUND function and arithmetic overflow

    遇到如下错误 Arithmetic overflow error converting expression to data type numeric. ), ); https://stackover ...

  9. JFreeChart简单用法

    需要用到的包 jfreechart-0.9.20.jar,jcommon-0.9.5.jar 创建一般步骤: 1.生成org.jfree.data.DefaultCategoryDataset对象,方 ...

  10. 数据读进set,进行后处理

    #include <iostream> #include <vector> #include <cstddef> #include <string> # ...