#coding = utf-8import osstr1 = 'd:/v3/'str2 = 'd:/v3/'fobj = open('D:/V3/txt/1.txt','rb')line = fobj.readline()while line: if(line.find('a') > 0):...
分类:
其他好文 时间:
2014-06-25 23:22:26
阅读次数:
270
monkey patch (猴子补丁) 用来在运行时动态修改已有的代码,而不需要修改原始代码。简单的monkey patch 实现:[python]#coding=utf-8def originalFunc(): print 'this is original function!'def modif...
分类:
编程语言 时间:
2014-06-24 22:50:22
阅读次数:
463
# -*- coding: utf-8 -*- # ==================== #File: python #Author: python #Date: 2014 #==================== __author__ = 'Administrator' #dict{键:值}...
分类:
编程语言 时间:
2014-06-22 23:34:14
阅读次数:
292
最近想用python写个切换host的小工具,折腾了好几天,终于实现了第一步。采用Tkinter编程,text控件接受输入,然后点击save按钮,保存内容到当前文件夹下,文件名为hostb,如下两张图片:直接上代码:#支持中文#!coding:gbk#导入需要的包from Tkinter impor...
分类:
编程语言 时间:
2014-06-22 23:24:49
阅读次数:
421
翻出google测试工程师的一道题目:
设计一个函数,任何语言都可以,实现以下功能:
一个句子,将句子中的单词全部倒排过来,但单词的字母顺序不变。eg. this is a real world输出结果为:world real a is this
笔者用Python实现如下:
#! /usr/bin/env python
# -* -coding:utf-8-*-
def...
分类:
编程语言 时间:
2014-06-22 16:54:45
阅读次数:
247
本文为学习笔记----总结!大部分为demo,一部分为学习中遇到的问题总结,包括怎么设置标签为中文等。matlab博大精深,需要用的时候再继续吧。
Pyplot tutorial
Demo地址为:点击打开链接
一个简单的例子:
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
plt.plot([1, 4, 9, 16])
p...
分类:
编程语言 时间:
2014-06-22 15:17:39
阅读次数:
415
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Have you thought about this?
Here are some good questions to ask before coding. Bonus points for y...
分类:
其他好文 时间:
2014-06-22 09:31:16
阅读次数:
220
在源文件的第一行或第二行添加:(必须在第一行或者第二行)
# -*- coding:utf-8 -*-
详细信息如下面解释:
Python对于decode&encode错误的默认处理方式为strict,也就是直接报错,而java使用replace的方式来处理了,因此java出现中文问题后会打印出很多"??"。此外,Python的默认的encoding是ASCII,而java的默认e...
分类:
编程语言 时间:
2014-06-21 23:25:51
阅读次数:
516
python自带调试工具库:pdb
# -*- coding:utf-8 -*-
def func(num):
s = num * 10
return s
if __name__ == '__main__':
print 'debug starting...'
print '*' * 10
print ‘debug ending…’
num...
分类:
数据库 时间:
2014-06-21 20:55:59
阅读次数:
357
5.引用当你创建一个对象并给它赋一个变量的时候,这个变量仅仅引用那个对象,而不是表示这个对象本身!也就是说,变量名指向你计算机中存储那个对象的内存。这被称作名称到对象的绑定。eg.[python]viewplaincopy#-*-coding:utf-8-*-shoplist=[‘apple‘,‘mango‘,‘carrot‘,‘banana‘]p..
分类:
编程语言 时间:
2014-06-21 19:08:15
阅读次数:
306