摘要:
Python之路,Day1 - Python基础1 https://www.cnblogs.com/alex3714/articles/5465198.html Python之路,Day2 - Python基础2 https://www.cnblogs.com/alex3714/articles/5 阅读全文
posted @ 2019-04-18 23:51
潇潇六月雨
阅读(2318)
评论(1)
推荐(1)
摘要:
修改全局变量 name = 'jason' def change_name(): global name name = 'Jason' 阅读全文
posted @ 2019-04-18 23:49
潇潇六月雨
阅读(139)
评论(0)
推荐(0)
摘要:
实现装饰器知识储备1、函数既“变量”2、高阶函数 a:把一个函数名当做实参传给另一个函数(在不修改被装饰函数源代码的情况下为其添加功能) b:返回值包含函数名(不能修改函数的调用方式)3、嵌套函数 高阶函数+嵌套函数 =》 装饰器 例子: # -*- coding:utf-8 -*-# Author 阅读全文
posted @ 2019-04-18 23:49
潇潇六月雨
阅读(101)
评论(0)
推荐(0)
摘要:
open('name.txt','r',encoding='utf-8') # r 读取文件模式open('name.txt','w',encoding='utf-8') # w 写文件open('name.txt','a',encoding='utf-8') # a 追加文本模式 f = open 阅读全文
posted @ 2019-04-18 23:49
潇潇六月雨
阅读(217)
评论(0)
推荐(0)
摘要:
创建字典 arr = {'one':{'o':'123'},'two':{'t':'to'}} arr.setdefault('one',{'omg':'o my gud'}) #查看字段是否存在,不存在就创建字典 b = { 'two':{'t':'to'}, 'three' : {'h':'ee 阅读全文
posted @ 2019-04-18 23:48
潇潇六月雨
阅读(120)
评论(0)
推荐(0)
摘要:
class NewClassName: #经典类class NewClassName(object): #新式类 *********************************************************************** 构造函数: #类调用时执行 __init_ 阅读全文
posted @ 2019-04-18 23:48
潇潇六月雨
阅读(163)
评论(0)
推荐(0)
摘要:
name.capitalize() 首字母大写name.casefold() 大写全部变小写name.center(50,"-") 输出 ' Alex Li 'name.count('lex') 统计 lex出现次数name.encode() 将字符串编码成bytes格式name.endswith( 阅读全文
posted @ 2019-04-18 23:47
潇潇六月雨
阅读(146)
评论(0)
推荐(0)
摘要:
abs() all() #全真返回True 否则False any() #全假返回False 否则True ascii() #返回 bin() #数字转换2进制 bool() #空返回False 否则返回True bytes('str',encoding="utf-8") #不可修改二进制格式 二进 阅读全文
posted @ 2019-04-18 23:46
潇潇六月雨
阅读(105)
评论(0)
推荐(0)
摘要:
1、定义模块:用来从逻辑上组织python代码(变量、函数、类、逻辑:实现一个功能),本质就是:.py结尾的python文件(文件名:test.py,对应的模块名:test)包:本质就是一个目录(必须带有一个__init__.py文件) 2、导入方法import module_nameimport 阅读全文
posted @ 2019-04-18 23:46
潇潇六月雨
阅读(135)
评论(0)
推荐(0)
摘要:
博客:http://www.cnblogs.com/alex3714/articles/5765046.html 列表生成式 [i*2 for i in range(10)] #创建时就生成,不调用也生成 生成器:( i*2 for i in range(10) ) #创建时记录算法,不调用算法不生 阅读全文
posted @ 2019-04-18 23:45
潇潇六月雨
阅读(140)
评论(0)
推荐(0)
摘要:
首先创建一个模块目录lib,然后在目录内创建一个模块为:aa.py 官方推荐: import importlib aa = importlib.import_module('lib.aa') c = aa.c() print(c) __import__导入方式 lib = __import__('l 阅读全文
posted @ 2019-04-18 23:44
潇潇六月雨
阅读(168)
评论(0)
推荐(0)
摘要:
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'},[' 阅读全文
posted @ 2019-04-18 23:43
潇潇六月雨
阅读(108)
评论(0)
推荐(0)
摘要:
http://www.cnblogs.com/alex3714/articles/5161349.html 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 import hashlib m 阅读全文
posted @ 2019-04-18 23:42
潇潇六月雨
阅读(206)
评论(0)
推荐(0)
摘要:
[DEFAULT]ServerAliveInterval = 45Compression = yesCompressionLevel = 9ForwardX11 = yes [bitbucket.org]User = hg [topsecret.server.com]Port = 50022Forw 阅读全文
posted @ 2019-04-18 23:42
潇潇六月雨
阅读(116)
评论(0)
推荐(0)
摘要:
服务器端 import socketimport os server = socket.socket()server.bind(( '127.0.0.1',9999 )) server.listen() #设置最大连接数 while True: conn, addr = server.accept( 阅读全文
posted @ 2019-04-18 23:41
潇潇六月雨
阅读(95)
评论(0)
推荐(0)
摘要:
Python中time模块详解http://qinxuye.me/article/details-about-time-module-in-python/ python模块part3http://blog.51cto.com/egon09/1840425 阅读全文
posted @ 2019-04-18 23:41
潇潇六月雨
阅读(88)
评论(0)
推荐(0)
摘要:
re模块 常用正则表达式符号 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹配任意字符,包括换行 '^' 匹配字符开头,若指定flags MULTILINE,这种也可以匹配上(r"^a","\nabc\neee",flags=re.MULTILINE) '$' 匹配字 阅读全文
posted @ 2019-04-18 23:40
潇潇六月雨
阅读(85)
评论(0)
推荐(0)
摘要:
学习网址:http://www.cnblogs.com/alex3714/articles/5161349.html import sys sys.stdout.write('fa') #打印输入字符串 sys.path.append() sys.argv: 实现从程序外部向程序传递参数。 sys. 阅读全文
posted @ 2019-04-18 23:40
潇潇六月雨
阅读(150)
评论(0)
推荐(0)
摘要:
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) # 阅读全文
posted @ 2019-04-18 23:39
潇潇六月雨
阅读(67)
评论(0)
推荐(0)
摘要:
python 2.7版本 不能解析中文在文件头部声明 # -*- coding:utf-8 -*- 注释使用 单行注释 #内容 多行注释 '''内容''' 给多行注释赋予一个变量后可直接使用变成多行文本 多行文本变量使用例子: '''Name:%s age %d Job %s'''%(name,ag 阅读全文
posted @ 2019-04-18 23:36
潇潇六月雨
阅读(112)
评论(0)
推荐(0)
浙公网安备 33010602011771号