11 2018 档案

摘要:#!/usr/bin/env pythonimport tensorflow as tf# 每个批次的大小batch_size = 50# 计算一共有多少个批次#n_batch = mnist.train.num_examples // batch_sizeinput_num = 16output_ 阅读全文
posted @ 2018-11-28 09:31 rongye 阅读(201) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tfinput_num = 16output_num = 11def create_file(path,output_num): with open(path,'r') as file: lines = file.r 阅读全文
posted @ 2018-11-27 21:49 rongye 阅读(191) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tfimport numpy as npdef read_and_decode(filename): # 读入dog_train.tfrecords filename_queue = tf.train.string_ 阅读全文
posted @ 2018-11-27 20:50 rongye 阅读(187) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tfimport numpy as np# write = tf.python_io.TFRecordWriter('train.tfrecords')# #img_raw = np.random.random_in 阅读全文
posted @ 2018-11-27 19:47 rongye 阅读(830) 评论(0) 推荐(0)
摘要:tensorflow读取数据-tfrecord格式 https://blog.csdn.net/happyhorizion/article/details/77894055 Tensorflow第三课数据加载 非图片数据 https://blog.csdn.net/clever_wr/article 阅读全文
posted @ 2018-11-27 11:43 rongye 阅读(217) 评论(0) 推荐(0)
摘要:https://github.com/fo40225/tensorflow-windows-wheel pip install tensorflow-1.5.0-cp36-cp36m-win_amd64.whl https://blog.csdn.net/z564359805/article/det 阅读全文
posted @ 2018-11-27 10:01 rongye 阅读(1146) 评论(0) 推荐(0)
摘要:Iter 4820, Testing Accuracy= 0.45184085Iter 4840, Testing Accuracy= 0.4525846Iter 4860, Testing Accuracy= 0.45332837Iter 4880, Testing Accuracy= 0.454 阅读全文
posted @ 2018-11-26 19:57 rongye 阅读(445) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tfimport osimport numpy as npimport refrom PIL import Imageimport matplotlib.pyplot as plt# In[2]:class Node 阅读全文
posted @ 2018-11-24 21:47 rongye 阅读(1157) 评论(0) 推荐(0)
摘要:import tensorflow as tfimport osimport tarfileimport requests# In[2]:# inception模型下载地址inception_pretrain_model_url = 'http://download.tensorflow.org/m 阅读全文
posted @ 2018-11-24 20:54 rongye 阅读(445) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python# coding: utf-8# In[1]:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[2]:# 载入数据集mnist = in 阅读全文
posted @ 2018-11-24 20:38 rongye 阅读(235) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-11-24 19:56 rongye 阅读(343) 评论(0) 推荐(0)
摘要:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[2]:# 载入数据集mnist = input_data.read_data_sets("MNIST_data/", one_h 阅读全文
posted @ 2018-11-24 19:16 rongye 阅读(266) 评论(0) 推荐(0)
摘要:Iter 0, Testing Accuracy= 0.9366Iter 1, Testing Accuracy= 0.9602Iter 2, Testing Accuracy= 0.9677Iter 3, Testing Accuracy= 0.9735Iter 4, Testing Accura 阅读全文
posted @ 2018-11-24 18:10 rongye 阅读(818) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[2]:mnist = input_data.read_data_sets('MNIST 阅读全文
posted @ 2018-11-23 22:53 rongye 阅读(1249) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datafrom tensorflow.contrib.tensorboard.plugins impo 阅读全文
posted @ 2018-11-23 20:04 rongye 阅读(447) 评论(0) 推荐(0)
摘要:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[2]:#载入数据集mnist = input_data.read_data_sets("MNIST_data",one_hot= 阅读全文
posted @ 2018-11-23 19:27 rongye 阅读(271) 评论(0) 推荐(0)
摘要:#C:\Users\mxf\venv\Scriptsimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[2]:# 载入数据集mnist = input_data.read_data 阅读全文
posted @ 2018-11-23 19:08 rongye 阅读(486) 评论(0) 推荐(0)
摘要:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#载入数据集mnist = input_data.read_data_sets("MNIST_data",one_hot=True)#每个 阅读全文
posted @ 2018-11-23 13:56 rongye 阅读(2380) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-11-23 13:43 rongye 阅读(198) 评论(0) 推荐(0)
摘要:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# 载入数据集mnist = input_data.read_data_sets("MNIST_data", one_hot=True)# 阅读全文
posted @ 2018-11-22 21:31 rongye 阅读(4628) 评论(0) 推荐(0)
摘要:# coding: utf-8# In[2]:import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# In[3]:#载入数据集mnist = input_data.read_data_set 阅读全文
posted @ 2018-11-22 17:38 rongye 阅读(409) 评论(0) 推荐(0)
摘要:# coding: utf-8# In[1]:import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt# In[6]:#使用numpy生成200个随机点x_data = np.linspace(-0.5,0.5, 阅读全文
posted @ 2018-11-22 17:05 rongye 阅读(373) 评论(0) 推荐(0)
摘要:#示例import numpy as npimport tensorflow as tfx_data = np.random.rand(100)y_data = .1 * x_data +.2## 构造一个线性模型优化器#优化 $y = kx+b$#待优化的参数b = tf.Variable(0.) 阅读全文
posted @ 2018-11-22 16:11 rongye 阅读(263) 评论(0) 推荐(0)
摘要:import tensorflow as tfc1 = tf.constant([[3,3]])c2 = tf.constant([[3],[2]])product = tf.matmul(c1 , c2)with tf.Session() as sess: reslut = sess.run(pr 阅读全文
posted @ 2018-11-22 16:10 rongye 阅读(247) 评论(0) 推荐(0)
摘要:import tensorflow as tf# print('haha')# a = tf.add(2,3)# print(a)# sess = tf.Session()# print(sess.run(a))# sess.close()# x = 2# y = 3# op1 = tf.add(x,y)# op2 = tf.multiply(x,y)# op3 = tf.pow(op2,op1)... 阅读全文
posted @ 2018-11-21 21:09 rongye 阅读(181) 评论(0) 推荐(0)
摘要:1、css重用 <style> 如果整个页面的宽度 > 900px时: { .c{ 共有 } .c1{ 独有 } } .c2{ 独有 } </style> <div class='c c1'></div> <div class='c c2'></div> 2、自适应 和 改变大小变形 左右滚动条的出 阅读全文
posted @ 2018-11-21 15:35 rongye 阅读(170) 评论(0) 推荐(0)
摘要:CSS 在标签上设置style属性: background-color: #2459a2; height: 48px; ... 编写css样式: 1. 标签的style属性 2. 写在head里面 style标签中写样式 - id选择区 #i1{ background-color: #2459a2; 阅读全文
posted @ 2018-11-20 20:48 rongye 阅读(160) 评论(0) 推荐(0)
摘要:HTML 1、一套规则,浏览器认识的规则。 2、开发者: 学习Html规则 开发后台程序: - 写Html文件(充当模板的作用) ****** - 数据库获取数据,然后替换到html文件的指定位置(Web框架) 3、本地测试 - 找到文件路径,直接浏览器打开 - pycharm打开测试 4、编写Ht 阅读全文
posted @ 2018-11-20 19:52 rongye 阅读(167) 评论(0) 推荐(0)
摘要:import socketdef handle_request(client): buf = client.recv(1024) client.send(bytes("HTTP/1.1 200 OK\r\n\r\n",encoding='utf-8')) f = open('index.html', 阅读全文
posted @ 2018-11-20 11:30 rongye 阅读(439) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/web-d/archive/2010/04/16/1713298.html 阅读全文
posted @ 2018-11-20 11:05 rongye 阅读(334) 评论(0) 推荐(0)
摘要:import selectorsimport socketsel = selectors.DefaultSelector()def accept(sock, mask): conn, addr = sock.accept() # Should be ready print('accepted', c 阅读全文
posted @ 2018-11-19 20:43 rongye 阅读(151) 评论(0) 推荐(0)
摘要:import selectimport socketimport queueserver = socket.socket()server.bind(('localhost',9000))server.listen(1000)server.setblocking(False) #不阻塞msg_dic 阅读全文
posted @ 2018-11-19 20:13 rongye 阅读(232) 评论(0) 推荐(0)
摘要:import sysimport socketimport timeimport geventfrom gevent import socket, monkeymonkey.patch_all()def server(port): s = socket.socket() s.bind(('0.0.0 阅读全文
posted @ 2018-11-19 16:04 rongye 阅读(265) 评论(0) 推荐(0)
摘要:GET: https://www.python.org/50114 bytes received from https://www.python.org/.GET: https://www.yahoo.com/505000 bytes received from https://www.yahoo. 阅读全文
posted @ 2018-11-19 15:46 rongye 阅读(391) 评论(0) 推荐(0)
摘要:Running in fooExplicit精确的 context内容 to barrunning func3 running func3 again Implicit context switch back to barExplicit context switch to foo again 阅读全文
posted @ 2018-11-19 15:32 rongye 阅读(248) 评论(0) 推荐(0)
摘要:12563478 阅读全文
posted @ 2018-11-19 15:21 rongye 阅读(150) 评论(0) 推荐(0)
摘要:import timeimport queuedef consumer(name): print(" >starting eating baozi...") while True: new_baozi = yield print("[%s] is eating baozi %s" % (name, 阅读全文
posted @ 2018-11-19 14:58 rongye 阅读(449) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Pool,freeze_supportimport timeimport osdef Foo(i): time.sleep(2) print("in process",os.getpid()) return i + 100de 阅读全文
posted @ 2018-11-19 13:58 rongye 阅读(212) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Lockdef f(l, i): #l.acquire() print('hello world', i) #l.release()if __name__ == '__main__': lock = Lock() for nu 阅读全文
posted @ 2018-11-19 11:58 rongye 阅读(178) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Managerimport osdef f(d, l): d[os.getpid()] =os.getpid() l.append(os.getpid()) print(l)if __name__ == '__main__': 阅读全文
posted @ 2018-11-19 11:48 rongye 阅读(220) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Pipedef f(conn): conn.send([42, None, 'hello from child']) conn.send([42, None, 'hello from child3']) print("",co 阅读全文
posted @ 2018-11-19 11:42 rongye 阅读(217) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Queueimport threading#import queue# def f(q):# q.put([42, None, 'hello'])def f(qq): print("in child:",qq.qsize()) 阅读全文
posted @ 2018-11-19 11:17 rongye 阅读(137) 评论(0) 推荐(0)
摘要:main process linemodule name: __main__parent process: 2728process id: 25524 called from child process function fmodule name: __mp_main__parent process 阅读全文
posted @ 2018-11-18 21:29 rongye 阅读(241) 评论(0) 推荐(0)
摘要:from multiprocessing import Process import time def f(name): time.sleep(2) print('hello', name) if __name__ == '__main__': p = Process(target=f, args= 阅读全文
posted @ 2018-11-18 21:19 rongye 阅读(152) 评论(0) 推荐(0)
摘要:import threading,timeimport queueq = queue.Queue(maxsize=10)def Producer(name): count = 1 while True: q.put("骨头%s" % count) print("生产了骨头",count) count 阅读全文
posted @ 2018-11-18 17:14 rongye 阅读(136) 评论(0) 推荐(0)
摘要:queue is especially useful in threaded programming when information must be exchanged safely between multiple threads. 阅读全文
posted @ 2018-11-18 16:51 rongye 阅读(168) 评论(0) 推荐(0)
摘要:import timeimport threadingevent = threading.Event()def lighter(): count = 0 event.set() #先设置绿灯 while True: if count >5 and count < 10: #改成红灯 event.cl 阅读全文
posted @ 2018-11-18 16:15 rongye 阅读(180) 评论(0) 推荐(0)
摘要:import threading, timedef run(n): semaphore.acquire() time.sleep(1) print("run the thread: %s\n" % n) semaphore.release()if __name__ == '__main__': se 阅读全文
posted @ 2018-11-18 15:04 rongye 阅读(192) 评论(0) 推荐(0)
摘要:import threading, timedef run1(): print("grab the first part data") lock.acquire() global num num += 1 lock.release() return numdef run2(): print("gra 阅读全文
posted @ 2018-11-18 14:59 rongye 阅读(206) 评论(0) 推荐(0)
摘要:import threadingimport timedef run(n): lock.acquire() global num num +=1 lock.release() time.sleep(1)lock = threading.Lock()num = 0t_objs = [] #存线程实例f 阅读全文
posted @ 2018-11-18 14:19 rongye 阅读(136) 评论(0) 推荐(0)
摘要:import threadingimport timedef run(n): print("task ",n ) time.sleep(2) print("task done",n)start_time = time.time()t_objs = [] #存线程实例for i in range(50 阅读全文
posted @ 2018-11-18 11:10 rongye 阅读(289) 评论(0) 推荐(0)
摘要:class BaseRequestHandler: """Base class for request handler classes. This class is instantiated for each request to be handled. The constructor sets t 阅读全文
posted @ 2018-11-17 16:49 rongye 阅读(1238) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/alex3714/articles/5830365.html 阅读全文
posted @ 2018-11-17 15:24 rongye 阅读(112) 评论(0) 推荐(0)
摘要:import hashlibimport socket ,os,timeserver = socket.socket()server.bind(('0.0.0.0',9999) )server.listen()while True: conn, addr = server.accept() prin 阅读全文
posted @ 2018-11-17 11:42 rongye 阅读(148) 评论(0) 推荐(0)
摘要:import hashlibm = hashlib.md5()m.update(b"test")m.update(b"abc")print(m.hexdigest())m2 = hashlib.md5()m2.update(b"testabc")print(m2.hexdigest()) 阅读全文
posted @ 2018-11-17 11:10 rongye 阅读(222) 评论(0) 推荐(0)
摘要:import socketclient = socket.socket()#client.connect(('192.168.16.200',9999))client.connect(('localhost',9999))while True: cmd = input(">>:").strip() 阅读全文
posted @ 2018-11-17 03:07 rongye 阅读(373) 评论(0) 推荐(0)
摘要:静态方法 与类无关,不能访问类里的任何属性和方法类方法 只能访问类变量属性@property 把一个方法变成一个静态属性, flight.status @status.setter flight.status = 3 @status.delter反射 getattr(obj,str) setattr 阅读全文
posted @ 2018-11-17 02:34 rongye 阅读(151) 评论(0) 推荐(0)
摘要:import importlib __import__('import_lib.metaclass') #这是解释器自己内部用的,到lib层#importlib.import_module('import_lib.metaclass') #与上面这句效果一样,官方建议用这个,到metaclass子层 阅读全文
posted @ 2018-11-17 01:52 rongye 阅读(88) 评论(0) 推荐(0)
摘要:#客户端import socketclient = socket.socket() #声明socket类型,同时生成socket连接对象client.connect(('localhost',6969))while True: msg = input(">>:").strip() if len(ms 阅读全文
posted @ 2018-11-16 23:13 rongye 阅读(164) 评论(0) 推荐(0)
摘要:class AlexError(Exception): def __init__(self, msg): self.message = msg # def __str__(self): # return 'sdfsf'try: raise AlexError('数据库连不上')except Alex 阅读全文
posted @ 2018-11-16 10:40 rongye 阅读(85) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/wupeiqi/articles/5017742.html python中的异常种类非常多,每个异常专门用于处理某一项异常!!! try: # 主代码块 passexcept KeyError,e: # 异常时,执行该块 passelse: # 主代码块 阅读全文
posted @ 2018-11-16 09:58 rongye 阅读(189) 评论(0) 推荐(0)
摘要:def bulk(self): print("%s is yelling...." %self.name)class Dog(object): def __init__(self,name): self.name = name def eat(self,food): print("%s is eat 阅读全文
posted @ 2018-11-16 09:18 rongye 阅读(140) 评论(0) 推荐(0)
摘要:class MyType(type): def __init__(self, what, bases=None, dict=None): print("--MyType init ") super(MyType, self).__init__(what, bases, dict) def __cal 阅读全文
posted @ 2018-11-15 21:48 rongye 阅读(211) 评论(0) 推荐(0)
摘要:# class Foo(object):# def __init__(self, name):# self.name = name### f = Foo("alex")# print(type(f))# print(type(Foo))def func(self): print('hello %s' 阅读全文
posted @ 2018-11-15 20:43 rongye 阅读(189) 评论(0) 推荐(0)
摘要:__setitem__ name alex__delitem__ sdfdsf 阅读全文
posted @ 2018-11-15 20:29 rongye 阅读(133) 评论(0) 推荐(0)
摘要:ChenRonghua is eating ddChenRonghua is talking http://www.cnblogs.com/alex3714/articles/5213184.html 阅读全文
posted @ 2018-11-15 19:54 rongye 阅读(395) 评论(0) 推荐(0)
摘要:Meow!Woof! Woof! 阅读全文
posted @ 2018-11-14 16:13 rongye 阅读(366) 评论(0) 推荐(0)
摘要:info of Teacher : lian name:lian age: 33 sex: M salary: 20000 course: Linux info of Student : ChenRonghua name:ChenRonghua age: 22 sex: M stu_id: 2018 阅读全文
posted @ 2018-11-14 16:05 rongye 阅读(177) 评论(0) 推荐(0)
摘要:lian born with 10000 moneylian is eattinglian is piao lian is sleepingman is sleepingChenRonghua is born a babylian is making friends with ChenRonghua 阅读全文
posted @ 2018-11-14 14:58 rongye 阅读(151) 评论(0) 推荐(0)
摘要:常用正则表达式符号 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹配任意字符,包括换行'^' 匹配字符开头,若指定flags MULTILINE,这种也可以匹配上(r"^a","\nabc\neee",flags=re.MULTILINE)'$' 匹配字符结尾,或e. 阅读全文
posted @ 2018-11-11 19:00 rongye 阅读(123) 评论(0) 推荐(0)
摘要:用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 阅读全文
posted @ 2018-11-11 18:24 rongye 阅读(128) 评论(0) 推荐(0)
摘要:用于生成和修改常见配置文档,当前模块的名称在 python 3.x 版本中变更为 configparser。 来看一个好多软件的常见文档格式如下 阅读全文
posted @ 2018-11-11 17:53 rongye 阅读(111) 评论(0) 推荐(0)
摘要:<?xml version="1.0"?><data> <country name="Liechtenstein"> <rank updated="yes">2</rank> <year>2008</year> <gdppc>141100</gdppc> <neighbor name="Austri 阅读全文
posted @ 2018-11-11 17:26 rongye 阅读(128) 评论(0) 推荐(0)
摘要:shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式import shelveimport datetimed = shelve.open('shelve_test') # 打开一个文件print(d.get("name"))pri 阅读全文
posted @ 2018-11-11 16:33 rongye 阅读(164) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport shutilf1 = open('本节笔记','r',encoding='utf-8')f2 = open('笔记2','w')shutil.copyfileobj(f1,f2)shutil.copyfile('本节笔记','笔记3')#shu 阅读全文
posted @ 2018-11-11 16:08 rongye 阅读(245) 评论(0) 推荐(0)
摘要:sys.argv 命令行参数List,第一个元素是程序本身路径sys.exit(n) 退出程序,正常退出时exit(0)sys.version 获取Python解释程序的版本信息sys.maxint 最大的Int值sys.path 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值sy 阅读全文
posted @ 2018-11-11 12:46 rongye 阅读(106) 评论(0) 推荐(0)
摘要:F:\python\s14\dya5\timeNoneNonec:\NoneF:\python\s14\dya5\time...NoneNoneNoneNone['os1.py', 'random1.py', 'time1.py']\ ;environ({'ALLUSERSPROFILE': 'C: 阅读全文
posted @ 2018-11-10 21:46 rongye 阅读(342) 评论(0) 推荐(0)
摘要:在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素。由于Python的time模块实现主要调用C库,所以各个平台可能有所不同。 UTC(Coordinated Universal Time,世界协调时)亦即格林威治天文时间, 阅读全文
posted @ 2018-11-10 21:10 rongye 阅读(146) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python#_*_encoding: utf-8_*_import randomprint (random.random()) #0.6445010863311293 #random.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0print 阅读全文
posted @ 2018-11-10 21:08 rongye 阅读(103) 评论(0) 推荐(0)
摘要:os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cdos.curdir 返回当前目录: ('.')os.pardir 获取当前目录的父目录字符串名:('..')os.makedirs('di 阅读全文
posted @ 2018-11-10 21:06 rongye 阅读(182) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport randomprint(random.random())print(random.randint(1,3))#0-3print(random.randrange(3))#0-2print(random.choice('abcdef'))#pri 阅读全文
posted @ 2018-11-10 20:47 rongye 阅读(158) 评论(0) 推荐(0)
摘要:1541851708.6755588-28800None 123time.struct_time(tm_year=2018, tm_mon=11, tm_mday=10, tm_hour=10, tm_min=8, tm_sec=29, tm_wday=5, tm_yday=314, tm_isds 阅读全文
posted @ 2018-11-10 20:11 rongye 阅读(359) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-11-10 16:22 rongye 阅读(116) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonprint('welcome to my atm')print(__file__)#相对路径import osimport sysprint(os.path.abspath(__file__))#绝对路径print(os.path.dirname(os.path.abspath(__file__)))#上级目录print(os.path.dirname(o... 阅读全文
posted @ 2018-11-09 19:42 rongye 阅读(175) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python#import json#不同语言交互,只能存简单的字符,集合等,不能存函数'''info = { 'name':'lian', 'age':22,}''''''f = open("test.test",'w')f.write(str(info))f.clo 阅读全文
posted @ 2018-11-09 19:10 rongye 阅读(166) 评论(0) 推荐(0)
摘要:TrueFalse<class 'str'> ["[1, 2, '\\u5f00\\u5916\\u6302\\u5f00\\u5916\\u6302']"]0b100111111011Falseb'Abcde' b'abcde'97bytearray(b'adcde')FalseW11901234 阅读全文
posted @ 2018-11-09 11:14 rongye 阅读(218) 评论(0) 推荐(0)
摘要:内置参数详解 https://docs.python.org/3/library/functions.html?highlight=built#ascii 阅读全文
posted @ 2018-11-09 09:23 rongye 阅读(163) 评论(0) 推荐(0)
摘要:A 准备吃包子啦!B 准备吃包子啦!老子开始准备做包子啦!做了1个包子,分两半!包子[0]来了,被[A]吃了!包子[0]来了,被[B]吃了!做了1个包子,分两半!包子[1]来了,被[A]吃了!包子[1]来了,被[B]吃了!做了1个包子,分两半!包子[2]来了,被[A]吃了!包子[2]来了,被[B]吃 阅读全文
posted @ 2018-11-09 09:05 rongye 阅读(130) 评论(0) 推荐(0)
摘要:g: 1g: 1g: 2g: 3g: 5g: 8Generator return value: done start loop 阅读全文
posted @ 2018-11-09 09:03 rongye 阅读(143) 评论(0) 推荐(0)
摘要:welcome to index pageUsername:lianPassword:abc123User has passed authenticationwelcome to home page welcomeldap++++++ 阅读全文
posted @ 2018-11-07 17:04 rongye 阅读(133) 评论(0) 推荐(0)
摘要:import timeuser,passwd = 'lian','abc123'def auth(func): def wrapper(*args,**kwargs): username = input("Username:").strip() password = input("Password: 阅读全文
posted @ 2018-11-07 11:58 rongye 阅读(113) 评论(0) 推荐(0)
摘要:import timedef timer(func): def deco(*args,**kwargs): start_time=time.time() func(*args,**kwargs) stop_time=time.time() print('the func run time is %s 阅读全文
posted @ 2018-11-07 11:40 rongye 阅读(152) 评论(0) 推荐(0)
摘要:变量可以指向函数,函数的参数能接收变量,那么一个函数就可以接收另一个函数作为参数,这种函数就称之为高阶函数。 1 2 3 4 5 6 def add(x,y,f): return f(x) + f(y) res = add(3,-6,abs) print(res) 1 2 3 4 5 6 def a 阅读全文
posted @ 2018-11-06 16:04 rongye 阅读(150) 评论(0) 推荐(0)
摘要:在函数内部,可以调用其他函数。如果一个函数在内部调用自身本身,这个函数就是递归函数。 1 2 3 4 5 6 7 8 9 10 11 12 13 def calc(n): print(n) if int(n/2) ==0: return n return calc(int(n/2)) calc(10 阅读全文
posted @ 2018-11-06 15:43 rongye 阅读(307) 评论(0) 推荐(0)
摘要:before change lian Oldboy edu.after change Lian YunNan Universitylian YunNan University 阅读全文
posted @ 2018-11-06 15:21 rongye 阅读(677) 评论(0) 推荐(0)
摘要:(1, 2, 3, 4, 5, 5)(1, 2, 4, 5, 5)1(2, 3, 4, 5, 6){'name': 'lian', 'age': 8, 'sex': 'f'}lian8{'name': 'lian', 'age': 8}lian8Lian{'age': 18, 'sex': 'm'} 阅读全文
posted @ 2018-11-06 15:03 rongye 阅读(122) 评论(0) 推荐(0)
摘要:in the test1in the test2in the test3None0(1, 'hello', ['alex', 'wupeiqi'], {'name': 'alex'}) 阅读全文
posted @ 2018-11-06 11:48 rongye 阅读(142) 评论(0) 推荐(0)
摘要:import timedef logger(): time_format = '%Y-%m-%d %X' time_current = time.strftime(time_format) with open('a.txt','a+') as f: f.write('%s end action\n' 阅读全文
posted @ 2018-11-06 11:33 rongye 阅读(169) 评论(0) 推荐(0)
摘要:详细文章: http://www.cnblogs.com/yuanchenqi/articles/5956943.html http://www.diveintopython3.net/strings.html 需知: 1.在python2默认编码是ASCII, python3里默认是unicode 阅读全文
posted @ 2018-11-06 10:18 rongye 阅读(305) 评论(0) 推荐(0)
摘要:为了避免打开文件后忘记关闭,可以通过管理上下文,即: 1 2 3 with open('log','r') as f: ... 1 2 3 with open('log','r') as f: ... 1 2 3 with open('log','r') as f: ... 1 2 3 with o 阅读全文
posted @ 2018-11-06 09:53 rongye 阅读(135) 评论(0) 推荐(0)
摘要:#逐行读写f = open('yesterday','r',encoding='utf-8')f_new = open('yesterday3','w',encoding="utf-8")for line in f: if '等我享受' in line: line = line.replace('等 阅读全文
posted @ 2018-11-06 09:44 rongye 阅读(134) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python#data = open("yesterday",encoding="utf-8").read()f = open("yesterday",'r',encoding="utf-8")#文件句柄,参数w为创建一个文件,#参数r为读,参数a为追加,可写#参数r+ 阅读全文
posted @ 2018-11-05 22:26 rongye 阅读(143) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport sys,timefor i in range(50): sys.stdout.write('#') sys.stdout.flush() time.sleep(0.1) 阅读全文
posted @ 2018-11-05 21:54 rongye 阅读(115) 评论(0) 推荐(0)
摘要:{1, 3, 4, 5, 6, 7, 9} {0, 2, 66, 4, 6, 8, 22}{4, 6}{4, 6}{0, 1, 2, 3, 4, 5, 6, 7, 66, 9, 8, 22}{0, 1, 2, 3, 4, 5, 6, 7, 66, 9, 8, 22}{1, 3, 5, 7, 9}{1 阅读全文
posted @ 2018-11-05 20:43 rongye 阅读(156) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythondata = { '北京':{ "昌平":{ "沙河":["oldboy","test"], "天通苑":["链家地产","我爱我家"] }, "朝阳":{ "望京":["奔驰","陌陌"], "国贸":{"CICC","HP"}, "东直门" 阅读全文
posted @ 2018-11-04 20:10 rongye 阅读(414) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythoninfo = { 'stu1101': "TengLan Wu", 'stu1102': "LongZe Luola", 'stu1103': "XiaoZe Maliya",}print(info)print(info['stu1101'])info['s 阅读全文
posted @ 2018-11-04 19:27 rongye 阅读(191) 评论(0) 推荐(0)
摘要:My name is {name} and my age is {year}5 my name is {name} and my age is {year} Falsemy name is {name} and my age is {year}3my name is lian and my age 阅读全文
posted @ 2018-11-04 18:39 rongye 阅读(158) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonproduct_list = [ ('Iphone',5800), ('Mac Pro',9800), ('Bike',800), ('Watch',10600), ('Coffee',31), ('Alex Python',120),]shopping_l 阅读全文
posted @ 2018-11-04 16:50 rongye 阅读(188) 评论(0) 推荐(0)
摘要:元组其实跟列表差不多,也是存一组数,只不是它一旦创建,便不能再修改,所以又叫只读列表 语法 1 names = ("alex","jack","eric") 1 names = ("alex","jack","eric") 1 names = ("alex","jack","eric") 1 nam 阅读全文
posted @ 2018-11-04 15:14 rongye 阅读(159) 评论(0) 推荐(0)
摘要:['alex', ['saving', 50]]['fengjie', ['saving', 50]] 阅读全文
posted @ 2018-11-04 11:52 rongye 阅读(175) 评论(0) 推荐(0)
摘要:我爱北京b'\xe6\x88\x91\xe7\x88\xb1\xe5\x8c\x97\xe4\xba\xac'我爱北京 阅读全文
posted @ 2018-11-04 11:08 rongye 阅读(136) 评论(0) 推荐(0)
摘要:1 result = 值1 if 条件 else 值2 1 result = 值1 if 条件 else 值2 1 result = 值1 if 条件 else 值2 1 result = 值1 if 条件 else 值2 result = 值1 if 条件 else 值2 如果条件为真:resul 阅读全文
posted @ 2018-11-04 10:29 rongye 阅读(135) 评论(0) 推荐(0)
摘要:#!/usr/bin/env pythonimport sysprint(sys.path)#打印环境变量print(sys.argv)#打印['F:/python/s14/day2/sys.py']及输入参数import oscmd_res = os.system("dir")#调用系统命令,直接 阅读全文
posted @ 2018-11-04 09:38 rongye 阅读(139) 评论(0) 推荐(0)
摘要:info1=''' info of %s age:%djob:%s''' %( name,int(age),job)print(info1) info2=''' info of {_name} age:{_age}job:{_job}'''.format( _name=name, _age=age, 阅读全文
posted @ 2018-11-04 09:07 rongye 阅读(352) 评论(0) 推荐(0)
摘要:有一种循环叫死循环,一经触发,就运行个天荒地老、海枯石烂。 海枯石烂代码 1 2 3 4 5 count = 0 while True: print("你是风儿我是沙,缠缠绵绵到天涯...",count) count +=1 1 2 3 4 5 count = 0 while True: print 阅读全文
posted @ 2018-11-04 08:58 rongye 阅读(183) 评论(0) 推荐(0)
摘要:最简单的循环10次 1 2 3 4 5 6 #_*_coding:utf-8_*_ __author__ = 'Alex Li' for i in range(10): print("loop:", i ) 1 2 3 4 5 6 #_*_coding:utf-8_*_ __author__ = ' 阅读全文
posted @ 2018-11-04 08:57 rongye 阅读(166) 评论(0) 推荐(0)
摘要:1 2 3 4 5 6 7 #!/usr/bin/env python #_*_coding:utf-8_*_ #name = raw_input("What is your name?") #only on python 2.x name = input("What is your name?") 阅读全文
posted @ 2018-11-04 08:55 rongye 阅读(149) 评论(0) 推荐(0)
摘要:python解释器在加载 .py 文件中的代码时,会对内容进行编码(默认ascill) ASCII(American Standard Code for Information Interchange,美国标准信息交换代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言,其最多 阅读全文
posted @ 2018-11-04 08:54 rongye 阅读(129) 评论(0) 推荐(0)
摘要:Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descri 阅读全文
posted @ 2018-11-04 08:53 rongye 阅读(172) 评论(0) 推荐(0)
摘要:windows 1 2 3 4 5 6 7 1、下载安装包 https://www.python.org/downloads/ 2、安装 默认安装路径:C:\python37 3、配置环境变量 【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中 阅读全文
posted @ 2018-11-04 08:50 rongye 阅读(126) 评论(0) 推荐(0)
摘要:In summary : Python 2.x is legacy, Python 3.x is the present and future of the language Python 3.0 was released in 2008. The final 2.x version 2.7 rel 阅读全文
posted @ 2018-11-04 08:49 rongye 阅读(243) 评论(0) 推荐(0)
摘要:当我们编写Python代码时,我们得到的是一个包含Python代码的以.py为扩展名的文本文件。要运行代码,就需要Python解释器去执行.py文件。 由于整个Python语言从规范到解释器都是开源的,所以理论上,只要水平够高,任何人都可以编写Python解释器来执行Python代码(当然难度很大) 阅读全文
posted @ 2018-11-04 08:42 rongye 阅读(135) 评论(0) 推荐(0)