随笔分类 - python
python 模块定义导入
摘要:1、定义模块:用来从逻辑上组织python代码(变量、函数、类、逻辑:实现一个功能),本质就是:.py结尾的python文件(文件名:test.py,对应的模块名:test)包:本质就是一个目录(必须带有一个__init__.py文件) 2、导入方法import module_nameimport
阅读全文
python 迭代器生成
摘要:博客:http://www.cnblogs.com/alex3714/articles/5765046.html 列表生成式 [i*2 for i in range(10)] #创建时就生成,不调用也生成 生成器:( i*2 for i in range(10) ) #创建时记录算法,不调用算法不生
阅读全文
python动态模块导入
摘要:首先创建一个模块目录lib,然后在目录内创建一个模块为:aa.py 官方推荐: import importlib aa = importlib.import_module('lib.aa') c = aa.c() print(c) __import__导入方式 lib = __import__('l
阅读全文
python 函数编程
摘要:def test1(): print('in the test1') def test2(): print('in the test2') return 1 def test3(): print('in the test3') return 3,'hello',{'name':'Jason'},['
阅读全文
python import hashllb
摘要:http://www.cnblogs.com/alex3714/articles/5161349.html 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 import hashlib m
阅读全文
python configparser
摘要:[DEFAULT]ServerAliveInterval = 45Compression = yesCompressionLevel = 9ForwardX11 = yes [bitbucket.org]User = hg [topsecret.server.com]Port = 50022Forw
阅读全文
python socket编程
摘要:服务器端 import socketimport os server = socket.socket()server.bind(( '127.0.0.1',9999 )) server.listen() #设置最大连接数 while True: conn, addr = server.accept(
阅读全文
python time模块
摘要:Python中time模块详解http://qinxuye.me/article/details-about-time-module-in-python/ python模块part3http://blog.51cto.com/egon09/1840425
阅读全文
python 正则
摘要:re模块 常用正则表达式符号 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹配任意字符,包括换行 '^' 匹配字符开头,若指定flags MULTILINE,这种也可以匹配上(r"^a","\nabc\neee",flags=re.MULTILINE) '$' 匹配字
阅读全文
python import
摘要:学习网址:http://www.cnblogs.com/alex3714/articles/5161349.html import sys sys.stdout.write('fa') #打印输入字符串 sys.path.append() sys.argv: 实现从程序外部向程序传递参数。 sys.
阅读全文
python 集合
摘要:list_1 = [1,4,5,7,3,6,7,9] list_1 = set(list_1) #列表排序,去重复 list_2 = set([2,6,0,66,8,4]) list_1.intersection( list_2 ) #获取两个列表的交集 list_1.union(list_2) #
阅读全文
python 笔记
摘要:python 2.7版本 不能解析中文在文件头部声明 # -*- coding:utf-8 -*- 注释使用 单行注释 #内容 多行注释 '''内容''' 给多行注释赋予一个变量后可直接使用变成多行文本 多行文本变量使用例子: '''Name:%s age %d Job %s'''%(name,ag
阅读全文
浙公网安备 33010602011771号