随笔分类 -  Python

摘要:python 代码: from ctypes import * import pygame import random import string import time if __name__ == '__main__': with open('log.txt','rb') as f: lines 阅读全文
posted @ 2023-10-25 14:53 *飞飞* 阅读(83) 评论(0) 推荐(0) 编辑
摘要:from openpyxl import Workbook from openpyxl import load_workbook wb= load_workbook(u"projects-shanghai.xlsx") ws = wb.worksheets[0] maxRow = ws.max_ro 阅读全文
posted @ 2023-06-15 16:46 *飞飞* 阅读(8) 评论(0) 推荐(0) 编辑
摘要:import schedule import time def job(): print('hello') schdule.every().day.at(‘10:00’).do(job) 或者: schedule.every().monday.do(job) schedule.every().wed 阅读全文
posted @ 2023-04-27 11:45 *飞飞* 阅读(8) 评论(0) 推荐(0) 编辑
摘要:Python import 包的机制是,import进来的和默认的系统的module了,都放在sys.module这个字典里面. 多个py文件再次import的时候,会先去sys.module里面检查是否已经import了,如果已经import了,就不再重复import,否则就import进来 im 阅读全文
posted @ 2017-12-11 09:38 *飞飞* 阅读(6766) 评论(0) 推荐(1) 编辑
摘要:http://blog.csdn.net/powerccna/article/details/8044222 在性能测试中,监控被测试服务器的性能指标是个重要的工作,包括CPU/Memory/IO/Network,但大多数人估计都是直接在被测试服务器的运行监控程序。我们开始也是这样做的。但这样做带来 阅读全文
posted @ 2016-07-25 23:11 *飞飞* 阅读(15950) 评论(3) 推荐(1) 编辑
摘要:列表 list append count,某个元素在列表中出现次数 extend,末尾一次性追加另一个序列中多个值 index,找出某个值第一个匹配项的索引位置 insert,将对象插入列表中 pop,移除列表中一个元素,并返回该元素的值 remove,移除某个值的第一个匹配项 reverse,反向 阅读全文
posted @ 2016-07-25 23:09 *飞飞* 阅读(404) 评论(0) 推荐(0) 编辑
摘要:doctest_test.py unittest_test.py 阅读全文
posted @ 2016-06-26 15:11 *飞飞* 阅读(278) 评论(0) 推荐(0) 编辑
摘要:threading_test.py forking_test.py select_test.py poll_test.py twisted_test.py twisted_LineReceiver.py 阅读全文
posted @ 2016-06-26 15:09 *飞飞* 阅读(352) 评论(0) 推荐(0) 编辑
摘要:client_test.py Server_test.py SocketServer.py urllib_test.py 阅读全文
posted @ 2016-06-26 15:04 *飞飞* 阅读(453) 评论(0) 推荐(0) 编辑
摘要:regular.py regular_test.py magnus.txt template.txt 阅读全文
posted @ 2016-06-26 15:01 *飞飞* 阅读(230) 评论(0) 推荐(0) 编辑
摘要:from distutils.core import setup setup(name='hello', version='1.0', description='test example', author='test', py_modules=['hello']) 阅读全文
posted @ 2016-06-26 14:56 *飞飞* 阅读(227) 评论(0) 推荐(0) 编辑
摘要:from tkinter import * def hello():print('hello world') win=Tk() win.title('hello tkinter') win.geometry('200x100') #x不是* btn=Button(win,text='hello',command=hello) btn.pack(expand=YES,fill=BOTH) main... 阅读全文
posted @ 2016-06-26 14:55 *飞飞* 阅读(212) 评论(0) 推荐(0) 编辑
摘要:import sqlite3,sys def convert(value): if value.startswith('~'): return value.strip('~') if not value: value='0' return float(value) conn=sqlite3.connect('food.db') curs=c... 阅读全文
posted @ 2016-06-26 14:53 *飞飞* 阅读(343) 评论(0) 推荐(0) 编辑
摘要:#方法,属性,私有化加双下划线 ''' __a 从外部无法访问,但是类的内部可以访问。实际上还是能在类外访问这些私有方法,尽管不应该这么做:s._A__a 如果不需要使用这种方法但是又不行让其他对象不要访问内部数据,可以使用单下划线 前面有下划线的名字都不会被带星号的imports语句导入 ''' class Person: def setname(self,name): ... 阅读全文
posted @ 2016-06-26 14:51 *飞飞* 阅读(134) 评论(0) 推荐(0) 编辑
摘要:#__init__ 构造方法,双下划线 #__del__ 析构方法,在对象就要被垃圾回收前调用。但发生调用 #的具体时间是不可知的。所以建议尽量避免使用__del__ print('-------example1') class A: def __init__(self): self.a='a' def printA(self): print(se... 阅读全文
posted @ 2016-06-26 14:49 *飞飞* 阅读(138) 评论(0) 推荐(0) 编辑
摘要:#导入模块 import sys sys.path sys.path.append('D:\program files\Python34\PyWorks') #hello.py文件路径 #不用append PyWorks路径也可以,因为D:\program files\Python34在sys.path中 import hello #第一次导入会执行,路径增加... 阅读全文
posted @ 2016-06-26 14:48 *飞飞* 阅读(270) 评论(0) 推荐(0) 编辑
摘要:#文档字符串 def square(x): 'calculates the square of the number x' return x*x square.__doc__ help(square) #列表做实参 #当2个变量同时引用一个列表时,他们的确是同时引一个列表用 #当在序列中做切片时,返回的切片总是一个副本 def change(x): x[0]='**... 阅读全文
posted @ 2016-06-26 14:47 *飞飞* 阅读(275) 评论(0) 推荐(0) 编辑
摘要:try: raise Exception except Exception as e: print(e) try: raise Exception('comment') except Exception as e: print(e) class SomeException(Exception): print('aa') pass try: ... 阅读全文
posted @ 2016-06-26 14:46 *飞飞* 阅读(195) 评论(0) 推荐(0) 编辑
摘要:#链式赋值 m=n=[1,2,3] m[0]=2 print(m,n) #m,n都改变了 x=y='xxx' y='yyy' print(x,y) #只有y 改变 #序列解包 x,y,z=1,2,3 print(x,y,z) try: x,y,z=1,2 #error x,y,z=1,2,3,4 #error except Exception as e: ... 阅读全文
posted @ 2016-06-26 14:44 *飞飞* 阅读(113) 评论(0) 推荐(0) 编辑
摘要:strings=['xxaa','xuo','fwefxxx','woeuxxfei'] print(strings) #替换方法1 for string in strings: if 'xx' in string: index=strings.index(string) strings[index]='00' print(strings) strings... 阅读全文
posted @ 2016-06-26 14:42 *飞飞* 阅读(197) 评论(0) 推荐(0) 编辑