欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于Tensorflow高階讀寫教程

 更新時(shí)間:2020年02月10日 10:44:30   作者:luchi007  
今天小編就為大家分享一篇基于Tensorflow高階讀寫教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

前言

tensorflow提供了多種讀寫方式,我們最常見的就是使用tf.placeholder()這種方法,使用這個(gè)方法需要我們提前處理好數(shù)據(jù)格式,不過這種處理方法也有缺陷:不便于存儲(chǔ)和不利于分布式處理,因此,TensorFlow提供了一個(gè)標(biāo)準(zhǔn)的讀寫格式和存儲(chǔ)協(xié)議,不僅如此,TensorFlow也提供了基于多線程隊(duì)列的讀取方式,高效而簡(jiǎn)潔,讀取速度也更快,據(jù)一個(gè)博主說速度能提高10倍,相當(dāng)?shù)恼T人.【下面的實(shí)驗(yàn)均是在tensorflow1.0的環(huán)境下進(jìn)行】

tensorflow的example解析

example協(xié)議

在TensorFlow官方github文檔里面,有個(gè)example.proto的文件,這個(gè)文件詳細(xì)說明了TensorFlow里面的example協(xié)議,下面我將簡(jiǎn)要敘述一下。

tensorflow的example包含的是基于key-value對(duì)的存儲(chǔ)方法,其中key是一個(gè)字符串,其映射到的是feature信息,feature包含三種類型:

BytesList:字符串列表

FloatList:浮點(diǎn)數(shù)列表

Int64List:64位整數(shù)列表

以上三種類型都是列表類型,意味著都能夠進(jìn)行拓展,但是也是因?yàn)檫@種彈性格式,所以在解析的時(shí)候,需要制定解析參數(shù),這個(gè)稍后會(huì)講。

在TensorFlow中,example是按照行讀的,這個(gè)需要時(shí)刻記住,比如存儲(chǔ) 矩陣,使用ByteList存儲(chǔ)的話,需要 大小的列表,按照每一行的讀取方式存放。

tf.tain.example

官方給了一個(gè)example的例子:

An Example for a movie recommendation application:
 features {
 feature {
 key: "age"
 value { float_list {
  value: 29.0
 }}
 }
 feature {
 key: "movie"
 value { bytes_list {
  value: "The Shawshank Redemption"
  value: "Fight Club"
 }}
 }
 feature {
 key: "movie_ratings"
 value { float_list {
  value: 9.0
  value: 9.7
 }}
 }
 feature {
 key: "suggestion"
 value { bytes_list {
  value: "Inception"
 }}
 }

上面的例子中包含一個(gè)features,features里面包含一些feature,和之前說的一樣,每個(gè)feature都是由鍵值對(duì)組成的,其key是一個(gè)字符串,其value是上面提到的三種類型之一。

Example中有幾個(gè)一致性規(guī)則需要注意:

如果一個(gè)example的feature K 的數(shù)據(jù)類型是 TT,那么所有其他的所有feature K都應(yīng)該是這個(gè)數(shù)據(jù)類型

feature K 的value list的item個(gè)數(shù)可能在不同的example中是不一樣多的,這個(gè)取決于你的需求

如果在一個(gè)example中沒有feature k,那么如果在解析的時(shí)候指定一個(gè)默認(rèn)值的話,那么將會(huì)返回一個(gè)默認(rèn)值

如果一個(gè)feature k 不包含任何的value值,那么將會(huì)返回一個(gè)空的tensor而不是默認(rèn)值

tf.train.SequenceExample

sequence_example表示的是一個(gè)或者多個(gè)sequences,同時(shí)還包括上下文context,其中,context表示的是feature_lists的總體特征,如數(shù)據(jù)集的長(zhǎng)度等,feature_list包含一個(gè)key,一個(gè)value,value表示的是features集合(feature_lists),同樣,官方源碼也給出了sequence_example的例子:

//ontext: {
 feature: {
 key : "locale"
 value: {
 bytes_list: {
  value: [ "pt_BR" ]
 }
 }
 }
 feature: {
 key : "age"
 value: {
 float_list: {
  value: [ 19.0 ]
 }
 }
 }
 feature: {
 key : "favorites"
 value: {
 bytes_list: {
  value: [ "Majesty Rose", "Savannah Outen", "One Direction" ]
 }
 }
 }
 }
 feature_lists: {
 feature_list: {
 key : "movie_ratings"
 value: {
 feature: {
  float_list: {
  value: [ 4.5 ]
  }
 }
 feature: {
  float_list: {
  value: [ 5.0 ]
  }
 }
 }
 }
 feature_list: {
 key : "movie_names"
 value: {
 feature: {
  bytes_list: {
  value: [ "The Shawshank Redemption" ]
  }
 }
 feature: {
  bytes_list: {
  value: [ "Fight Club" ]
  }
 }
 }
 }
 feature_list: {
 key : "actors"
 value: {
 feature: {
  bytes_list: {
  value: [ "Tim Robbins", "Morgan Freeman" ]
  }
 }
 feature: {
  bytes_list: {
  value: [ "Brad Pitt", "Edward Norton", "Helena Bonham Carter" ]
  }
 }
 }
 }
 }

一致性的sequence_example遵循以下規(guī)則:

1、context中,所有feature k要保持?jǐn)?shù)據(jù)類型一致性

2、一些example中的某些feature_lists L可能會(huì)丟失,如果在解析的時(shí)候允許為空的話,那么在解析的時(shí)候回返回一個(gè)空的list

3、feature_lists可能是空的

4、如果一個(gè)feature_list是非空的,那么其里面的所有feature都必須是一個(gè)數(shù)據(jù)類型

5、如果一個(gè)feature_list是非空的,那么對(duì)于里面的feature的長(zhǎng)度是不是需要一樣的,這個(gè)取決于解析時(shí)候的參數(shù)

tensorflow 的parse example解析

在官方代碼*[parsing_ops.py]*中有關(guān)于parse example的詳細(xì)介紹,我在這里再敘述一下。

tf.parse_example

來看tf.parse_example的方法定義:

def parse_example(serialized, features, name=None, example_names=None)

parse_example是把example解析為詞典型的tensor

參數(shù)含義:

serialized:一個(gè)batch的序列化的example

features:解析example的規(guī)則

name:當(dāng)前操作的名字

example_name:當(dāng)前解析example的proto名稱

這里重點(diǎn)要說的是第二個(gè)參數(shù),也就是features,features是把serialized的example中按照鍵值映射到三種tensor: 1,VarlenFeature 2, SparseFeature 3,FixedLenFeature

下面對(duì)這三種映射方式做一個(gè)簡(jiǎn)要的敘述:

VarlenFeature

是按照鍵值把example的value映射到SpareTensor對(duì)象,假設(shè)我們有如下的serialized數(shù)據(jù):

 serialized = [
 features
 { feature { key: "ft" value { float_list { value: [1.0, 2.0] } } } },
 features
 { feature []},
 features
 { feature { key: "ft" value { float_list { value: [3.0] } } }
 ]

使用VarLenFeatures方法:

features={
 "ft":tf.VarLenFeature(tf.float32)
}

那么我們將得到的是:

{"ft": SparseTensor(indices=[[0, 0], [0, 1], [2, 0]],
   values=[1.0, 2.0, 3.0],
   dense_shape=(3, 2)) }

可見,顯示的indices是ft值的索引,values是值,dense_shape是indices的shape

FixedLenFeature

而FixedLenFeature是按照鍵值對(duì)將features映射到大小為[serilized.size(),df.shape]的矩陣,這里的FixLenFeature指的是每個(gè)鍵值對(duì)應(yīng)的feature的size是一樣的。對(duì)于上面的例子,如果使用:

features: {
 "ft": FixedLenFeature([2], dtype=tf.float32, default_value=-1),
 }

那么我們將得到:

{"ft": [[1.0, 2.0], [3.0, -1.0]]}

可見返回的值是一個(gè)[2,2]的矩陣,如果返回的長(zhǎng)度不足給定的長(zhǎng)度,那么將會(huì)使用默認(rèn)值去填充。

【注意:】

事實(shí)上,在TensorFlow1.0環(huán)境下,根據(jù)官方文檔上的內(nèi)容,我們是能夠得到VarLenFeature的值,但是得不到FixLenFeature的值,因此建議如果使用定長(zhǎng)的FixedLenFeature,一定要保證對(duì)應(yīng)的數(shù)據(jù)是等長(zhǎng)的。

做個(gè)試驗(yàn)來說明:

#coding=utf-8

import tensorflow as tf
import os
keys=[[1.0],[],[2.0,3.0]]
sess=tf.InteractiveSession()
sess.run(tf.global_variables_initializer())

def make_example(key):
 example = tf.train.Example(features=tf.train.Features(
 feature={
  'ft':tf.train.Feature(float_list=tf.train.FloatList(value=key))
 }
 ))
 return example

filename="tmp.tfrecords"
if os.path.exists(filename):
 os.remove(filename)
writer = tf.python_io.TFRecordWriter(filename)
for key in keys:
 ex = make_example(key)
 writer.write(ex.SerializeToString())
writer.close()

reader = tf.TFRecordReader()
filename_queue = tf.train.string_input_producer(["tmp.tfrecords"],num_epochs=1)
_,serialized_example =reader.read(filename_queue)

# coord = tf.train.Coordinator()
# threads = tf.train.start_queue_runners(sess=sess,coord=coord)

batch = tf.train.batch(tensors=[serialized_example],batch_size=3)

features={
 "ft":tf.VarLenFeature(tf.float32)
}
#key_parsed = tf.parse_single_example(make_example([1,2,3]).SerializeToString(),features)
key_parsed = tf.parse_example(batch,features)
#start the queue
print tf.contrib.learn.run_n(key_parsed)

#[]means scalar

features={
 "ft":tf.FixedLenFeature(shape=[2],dtype=tf.float32)
}

key_parsed = tf.parse_example(batch,features)

print tf.contrib.learn.run_n(key_parsed)

結(jié)果返回如下:

[{'ft': SparseTensorValue(indices=array([[0, 0],
 [2, 0],
 [2, 1]]), values=array([ 1., 2., 3.], dtype=float32), dense_shape=array([3, 2]))}]

InvalidArgumentError (see above for traceback): Name: <unknown>, Key: ft, Index: 0. Number of float values != expected. Values size: 1 but output shape: [2]


可見,對(duì)于VarLenFeature,是能返回正常結(jié)果的,但是對(duì)于FixedLenFeature則返回size不對(duì),可見如果對(duì)于邊長(zhǎng)的數(shù)據(jù)還是不要使用FixedLenFeature為好。

如果把數(shù)據(jù)設(shè)置為[[1.0,2.0],[2.0,3.0]],那么FixedLenFeature返回的是:

[{'ft': array([[ 1., 2.],
 [ 2., 3.]], dtype=float32)}]

這是正確的結(jié)果。

SparseFeature可以從下面的例子來說明:

`serialized`:
 ```
 [
 features {
 feature { key: "val" value { float_list { value: [ 0.5, -1.0 ] } } }
 feature { key: "ix" value { int64_list { value: [ 3, 20 ] } } }
 },
 features {
 feature { key: "val" value { float_list { value: [ 0.0 ] } } }
 feature { key: "ix" value { int64_list { value: [ 42 ] } } }
 }
 ]
 ```
 And arguments
 ```
 example_names: ["input0", "input1"],
 features: {
 "sparse": SparseFeature(
  index_key="ix", value_key="val", dtype=tf.float32, size=100),
 }
 ```
 Then the output is a dictionary:
 ```python
 {
 "sparse": SparseTensor(
 indices=[[0, 3], [0, 20], [1, 42]],
 values=[0.5, -1.0, 0.0]
 dense_shape=[2, 100]),
 }
 ```

現(xiàn)在明白了Example的協(xié)議和tf.parse_example的方法之后,我們?cè)倏纯纯磶讉€(gè)簡(jiǎn)單的parse_example

tf.parse_single_example

區(qū)別于tf.parse_example,tf.parse_single_example只是少了一個(gè)batch而已,其余的都是一樣的,我們看代碼:

#coding=utf-8

import tensorflow as tf
import os

sess=tf.InteractiveSession()
sess.run(tf.global_variables_initializer())

def make_example(key):
 example = tf.train.Example(features=tf.train.Features(
 feature={
  'ft':tf.train.Feature(float_list=tf.train.FloatList(value=key))
 }
 ))
 return example

features={
 "ft":tf.FixedLenFeature(shape=[3],dtype=tf.float32)
}

key_parsed = tf.parse_single_example(make_example([1.0,2.0,3.0]).SerializeToString(),features)

print tf.contrib.learn.run_n(key_parsed)

結(jié)果返回為:

[{'ft': array([ 1., 2., 3.], dtype=float32)}]

tf.parse_single_sequence_example

tf.parse_single_sequence_example對(duì)應(yīng)的是tf.train,SequenceExample,我們以下面代碼說明,single_sequence_example的用法:

#coding=utf-8

import tensorflow as tf
import os
keys=[[1.0,2.0],[2.0,3.0]]
sess=tf.InteractiveSession()
sess.run(tf.global_variables_initializer())

def make_example(locale,age,score,times):

 example = tf.train.SequenceExample(
 context=tf.train.Features(
  feature={
  "locale":tf.train.Feature(bytes_list=tf.train.BytesList(value=[locale])),
  "age":tf.train.Feature(int64_list=tf.train.Int64List(value=[age]))
 }),
 feature_lists=tf.train.FeatureLists(
  feature_list={
  "movie_rating":tf.train.FeatureList(feature=[tf.train.Feature(float_list=tf.train.FloatList(value=score)) for i in range(times)])
  }
 )
 )
 return example.SerializeToString()

context_features = {
 "locale": tf.FixedLenFeature([],dtype=tf.string),
 "age": tf.FixedLenFeature([],dtype=tf.int64)
}
sequence_features = {
 "movie_rating": tf.FixedLenSequenceFeature([3], dtype=tf.float32,allow_missing=True)
}

context_parsed, sequence_parsed = tf.parse_single_sequence_example(make_example("china",24,[1.0,3.5,4.0],2),context_features=context_features,sequence_features=sequence_features)

print tf.contrib.learn.run_n(context_parsed)
print tf.contrib.learn.run_n(sequence_parsed)

結(jié)果打印為:

[{'locale': 'china', 'age': 24}]

[{'movie_rating': array([[ 1. , 3.5, 4. ],
 [ 1. , 3.5, 4. ]], dtype=float32)}]

tf.parse_single_sequence_example的自動(dòng)補(bǔ)齊

在常用的文本處理方面,由于文本經(jīng)常是非定長(zhǎng)的,因此需要經(jīng)常補(bǔ)齊操作,例如使用CNN進(jìn)行文本分類的時(shí)候就需要進(jìn)行padding操作,通常我們把padding的索引設(shè)置為0,而且在文本預(yù)處理的時(shí)候也需要額外的代碼進(jìn)行處理,而TensorFlow提供了一個(gè)比較好的自動(dòng)補(bǔ)齊工具,就是在tf.train.batch里面把參數(shù)dynamic_pad設(shè)置成True,樣例如下:

#coding=utf-8

import tensorflow as tf
import os
keys=[[1,2],[2]]
sess=tf.InteractiveSession()
sess.run(tf.global_variables_initializer())



def make_example(key):

 example = tf.train.SequenceExample(
 context=tf.train.Features(
  feature={
  "length":tf.train.Feature(int64_list=tf.train.Int64List(value=[len(key)]))
 }),
 feature_lists=tf.train.FeatureLists(
  feature_list={
  "index":tf.train.FeatureList(feature=[tf.train.Feature(int64_list=tf.train.Int64List(value=[key[i]])) for i in range(len(key))])
  }
 )
 )
 return example.SerializeToString()


filename="tmp.tfrecords"
if os.path.exists(filename):
 os.remove(filename)
writer = tf.python_io.TFRecordWriter(filename)
for key in keys:
 ex = make_example(key)
 writer.write(ex)
writer.close()

reader = tf.TFRecordReader()
filename_queue = tf.train.string_input_producer(["tmp.tfrecords"],num_epochs=1)
_,serialized_example =reader.read(filename_queue)

# coord = tf.train.Coordinator()
# threads = tf.train.start_queue_runners(sess=sess,coord=coord)

context_features={
 "length":tf.FixedLenFeature([],dtype=tf.int64)
}
sequence_features={
 "index":tf.FixedLenSequenceFeature([],dtype=tf.int64)
}

context_parsed, sequence_parsed = tf.parse_single_sequence_example(
 serialized=serialized_example,
 context_features=context_features,
 sequence_features=sequence_features
)

batch_data = tf.train.batch(tensors=[sequence_parsed['index']],batch_size=2,dynamic_pad=True)
result = tf.contrib.learn.run_n({"index":batch_data})

print result

打印結(jié)果如下:

[{'index': array([[1, 2],
 [2, 0]])}]

可見還是比較好用的功能

tensorflow的TFRecords讀取

在上面的部分,我們展示了關(guān)于tensorflow的example的用法和解析過程,那么我們?cè)撊绾问褂盟鼈兡??其?shí)在上面的幾段代碼里面也有體現(xiàn),就是TFRecords進(jìn)行讀寫,TFRecords讀寫其實(shí)很簡(jiǎn)單,tensorflow提供了兩個(gè)方法:

tf.TFRecordReader

tf.TFRecordWriter

首先我們看下第二個(gè),也就是tf.TFRecordWritre,之所以先看第二個(gè)的原因是第一個(gè)Reader將和batch一起在下一節(jié)講述。

關(guān)于TFRecordWriter,可以用下面代碼說明,假設(shè)serilized_object是一個(gè)已經(jīng)序列化好的example,那么其寫的過程如下:

writer = tf.python_io.TFRecordWriter(filename)
writer.write(serilized_object)
writer.close()

tensorflow的多線程batch讀取

這一節(jié)主要關(guān)注的是基于TFRecords的讀取的方法和batch操作,我們可以回看一下之前的文章的batch操作:

Batching

def read_my_file_format(filename_queue):
 reader = tf.SomeReader()
 key, record_string = reader.read(filename_queue)
 example, label = tf.some_decoder(record_string)
 processed_example = some_processing(example)
 return processed_example, label

def input_pipeline(filenames, batch_size, num_epochs=None):
 filename_queue = tf.train.string_input_producer(
 filenames, num_epochs=num_epochs, shuffle=True)
 example, label = read_my_file_format(filename_queue)
 # min_after_dequeue defines how big a buffer we will randomly sample
 # from -- bigger means better shuffling but slower start up and more
 # memory used.
 # capacity must be larger than min_after_dequeue and the amount larger
 # determines the maximum we will prefetch. Recommendation:
 # min_after_dequeue + (num_threads + a small safety margin) * batch_size
 min_after_dequeue = 10000
 capacity = min_after_dequeue + 3 * batch_size
 example_batch, label_batch = tf.train.shuffle_batch(
 [example, label], batch_size=batch_size, capacity=capacity,
 min_after_dequeue=min_after_dequeue)
 return example_batch, label_batch

這里我們把tf.SomeReader()換成tf.TFRecordReader()即可,然后再把tf.some_decoder換成我們自定義的decoder,當(dāng)然在decoder里面我們可以自己指定parser(也就是上文提到的內(nèi)容),然后我們使用tf.train.batch或者tf.train.shuffle_batch等操作獲取到我們需要送入網(wǎng)絡(luò)訓(xùn)練的batch參數(shù)即可。

多線程讀取batch實(shí)例

我使用了softmax回歸做一個(gè)簡(jiǎn)單的示例,下面是一個(gè)多線程讀取batch的實(shí)例主要代碼:

#coding=utf-8
"""
author:luchi
date:24/4/2017
desc:training logistic regression
"""
import tensorflow as tf
from model import Logistic

def read_my_file_format(filename_queue):
 reader = tf.TFRecordReader()
 _,serilized_example = reader.read(filename_queue)

 #parsing example
 features = tf.parse_single_example(serilized_example,
 features={
  "data":tf.FixedLenFeature([2],tf.float32),
  "label":tf.FixedLenFeature([],tf.int64)
 }

 )

 #decode from raw data,there indeed do not to change ,but to show common step , i write a case here

 # data = tf.cast(features['data'],tf.float32)
 # label = tf.cast(features['label'],tf.int64)

 return features['data'],features['label']


def input_pipeline(filenames, batch_size, num_epochs=100):


 filename_queue = tf.train.string_input_producer([filenames],num_epochs=num_epochs)
 data,label=read_my_file_format(filename_queue)

 datas,labels = tf.train.shuffle_batch([data,label],batch_size=batch_size,num_threads=5,
      capacity=1000+3*batch_size,min_after_dequeue=1000)
 return datas,labels

class config():
 data_dim=2
 label_num=2
 learining_rate=0.1
 init_scale=0.01

def run_training():

 with tf.Graph().as_default(), tf.Session() as sess:

 datas,labels = input_pipeline("reg.tfrecords",32)

 c = config()
 initializer = tf.random_uniform_initializer(-1*c.init_scale,1*c.init_scale)

 with tf.variable_scope("model",initializer=initializer):
  model = Logistic(config=c,data=datas,label=labels)

 fetches = [model.train_op,model.accuracy,model.loss]
 feed_dict={}

 #init
 init_op = tf.group(tf.global_variables_initializer(),
   tf.local_variables_initializer())
 sess.run(init_op)

 coord = tf.train.Coordinator()
 threads = tf.train.start_queue_runners(sess=sess,coord=coord)
 try:
  while not coord.should_stop():

  # fetches = [model.train_op,model.accuracy,model.loss]
  # feed_dict={}
  # feed_dict[model.data]=sess.run(datas)
  # feed_dict[model.label]=sess.run(labels)
  # _,accuracy,loss= sess.run(fetches,feed_dict)
  _,accuracy,loss= sess.run(fetches,feed_dict)
  print("the loss is %f and the accuracy is %f"%(loss,accuracy))
 except tf.errors.OutOfRangeError:
  print("done training")
 finally:
  coord.request_stop()
 coord.join(threads)
 sess.close()

def main():
 run_training()

if __name__=='__main__':
 main()

這里有幾個(gè)坑需要說明一下:

使用了string_input_producer指定num_epochs之后,在初始化的時(shí)候需要使用:

init_op = tf.group(tf.global_variables_initializer(),
   tf.local_variables_initializer())
sess.run(init_op)

要不然會(huì)報(bào)錯(cuò)

2. 使用了從文件讀取batch之后,就不需要設(shè)置tf.placeholder了【非常重要】,我在這個(gè)坑里呆了好久,如果使用了tf.placeholder一是會(huì)報(bào)錯(cuò)為tensor對(duì)象能送入到tf.placeholder中,另外一個(gè)是就算使用sess.run(batch_data),也會(huì)存在模型不能收斂的問題,所以切記切記

結(jié)果顯示如下:

the loss is 0.156685 and the accuracy is 0.937500
the loss is 0.185438 and the accuracy is 0.968750
the loss is 0.092628 and the accuracy is 0.968750
the loss is 0.059271 and the accuracy is 1.000000
the loss is 0.088685 and the accuracy is 0.968750
the loss is 0.271341 and the accuracy is 0.968750
the loss is 0.244190 and the accuracy is 0.968750
the loss is 0.136841 and the accuracy is 0.968750
the loss is 0.115607 and the accuracy is 0.937500
the loss is 0.080254 and the accuracy is 1.000000

完整的代碼見我的GitHub

以上這篇基于Tensorflow高階讀寫教程就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

  • Python格式化日期時(shí)間操作示例

    Python格式化日期時(shí)間操作示例

    這篇文章主要介紹了Python格式化日期時(shí)間操作,結(jié)合實(shí)例形式分析了Python使用time模塊針對(duì)日期時(shí)間的獲取、轉(zhuǎn)換、格式化、判斷等相關(guān)操作技巧,需要的朋友可以參考下
    2018-06-06
  • Python檢查圖片是否損壞及圖片類型是否正確過程詳解

    Python檢查圖片是否損壞及圖片類型是否正確過程詳解

    這篇文章主要介紹了Python檢查圖片是否損壞及圖片類型是否正確過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-09-09
  • 如何在Cloud Studio上執(zhí)行Python代碼?

    如何在Cloud Studio上執(zhí)行Python代碼?

    這篇文章主要介紹了如何在Cloud Studio上執(zhí)行Python代碼?,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-08-08
  • Python reversed函數(shù)及使用方法解析

    Python reversed函數(shù)及使用方法解析

    這篇文章主要介紹了Python reversed函數(shù)及使用方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03
  • python路徑的寫法及目錄的獲取方式

    python路徑的寫法及目錄的獲取方式

    今天小編就為大家分享一篇python路徑的寫法及目錄的獲取方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • python使用requests.session模擬登錄

    python使用requests.session模擬登錄

    最近開發(fā)一套接口,寫個(gè)Python腳本,使用requests.session模擬一下登錄.本文通過實(shí)例代碼給大家介紹python使用requests.session模擬登錄,感興趣的朋友跟隨小編一起看看吧
    2019-08-08
  • 利用Python實(shí)現(xiàn)自動(dòng)生成小學(xué)生計(jì)算題

    利用Python實(shí)現(xiàn)自動(dòng)生成小學(xué)生計(jì)算題

    過年期間發(fā)現(xiàn)小外甥已經(jīng)上小學(xué)了,我姐說老師今天給他們布置了寒假作業(yè):每天堅(jiān)持做乘法和加減法混合運(yùn)算。這我必須幫幫忙,用Python寫了一段自動(dòng)生成小學(xué)生計(jì)算題的代碼,希望外甥不要太感謝我
    2023-02-02
  • 通過Python把學(xué)姐照片做成拼圖游戲

    通過Python把學(xué)姐照片做成拼圖游戲

    馬上就到畢業(yè)季了,你心中的那個(gè)學(xué)姐,你真的放下了嗎?本文將用pygame為你的學(xué)姐,定制開發(fā)一個(gè)拼圖游戲,感興趣的快跟隨小編一起學(xué)習(xí)一下
    2022-02-02
  • 68行Python代碼實(shí)現(xiàn)帶難度升級(jí)的貪吃蛇

    68行Python代碼實(shí)現(xiàn)帶難度升級(jí)的貪吃蛇

    本文主要介紹了Python代碼實(shí)現(xiàn)帶難度升級(jí)的貪吃蛇,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • python中xlrd模塊的使用詳解

    python中xlrd模塊的使用詳解

    這篇文章主要介紹了python中xlrd模塊的使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02

最新評(píng)論