# -*- 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. 基于cocos2d开发的android小游戏——採花仙

    /*cocos 2d 已经成为了如今移动端游戏开发的强有力的工具,眼下主流游戏中多採用cocos 2d游戏引擎. 我也尝试了一下该引擎.我是用的是cocos2d-android,以后要移植到Cocos ...

  2. [Unity3D]Unity3D游戏开发之从Unity3D到Eclipse

    ---------------------------------------------------------------------------------------------------- ...

  3. 《编程导论(Java)&#183;3.1.2 方法》之 副作用

    4. 副作用 在一些语言如Pascal中,子程序被分成两种:函数和过程.尽管Java没有强制性地要求将方法区分为命令和函数.然而这样的差别对于良好地设计程序有非常大的帮助[1]. 首先说明一个概念:副 ...

  4. 【DataStructure】Charming usage of Set in the java

    In an attempt to remove duplicate elements from list, I go to the lengths to take advantage of  meth ...

  5. git基础之创建ssh公钥和密钥

    用git管理过程中,不想每次输入username和password.解决的方法例如以下; 1 . 链接换成ssh协议. 2 . 生成公钥. 3. 加入ssh公钥到gitserver. 打开gitbas ...

  6. c#控件重绘的问题

    1.当Panel有背景图像的时候,往Panel添加控件(带图像),画面会非常闪烁,所以,Panel尽量不要带背景图像 2.带背景图像可以参考designer.cs里面的写法... 添加Control之 ...

  7. HDU 5475An easy problem 离线set/线段树

    An easy problem Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  8. HDU4403 A very hard Aoshu problem DFS

    A very hard Aoshu problem                           Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  9. [mac]WireShark检測不到网卡怎么办?

    wireshark是一个很好用的抓包工具,有windows版本号和mac版本号,在mac下安装wireshark,启动后发现提示"There are no interfaces on whi ...

  10. 【BZOJ 3732】 Network

    [题目链接] 点击打开链接 [算法] 求出这个图的最小生成树,对于每次询问,用倍增法求出最近公共祖先,查询最小生成树上两点路径上的最大值 算法的正确性?            假设x和y在最小生成树中 ...