Python手寫數字識別之路1

2021-10-02 04:40:03 字數 3294 閱讀 8396

元組字串

格式化字串

序列雖然python是從c語言發展而來,但是我覺得和c語言區別巨大。

首先玩乙個小遊戲

"python"

import random

counts =

3answer = random.randint(1,

10)#生成乙個隨機數,guess

while counts >0:

temp =

input

("enter number "

) guess =

int(temp)

if guess == answer:

print

("right"

)break

else

:if guess < answer:

print

("small"

)else

:print

("big"

) counts = counts -

1print

("game over"

)

member =

['小明'

,'弱音'

,'狂三'

,'光輝'

]for i in member:

print

(i,len

(i))

for i in

range(0

,20,3

):# 步進為3

print

(i)

while ture:

code

member =

['小明'

,'弱音'

,'狂三'

,'光輝'

]for i in member:

print

(i,len

(i))

'洛天依'

)for i in member:

print

(i,len

(i))

member.extend(

['東方'

,'**'])

for i in member:

print

(i,len

(i))

member.insert(1,

'手寫數字識別'

)for i in member:

print

(i,len

(i))

member.remove(

'手寫數字識別'

)for i in member:

print

(i)del member[1]

for i in member:

print

(i)member.pop(1)

for i in member:

print

(i)

member[1:

3]for i in member[1:

3]:print

(i)

list1 =

[123

]list2 =

[456

]print

(list1 > list2)

list1 =

[123

,456

]list2 =

[234

,123

]print

(list1 > list2)

list3 =

[123

,456

]print

((list1 < list2)

and(list1 == list3)

)list4 = list1 + list2

print

(list4)

list3 *

3list3 +=

3123

in list3

2not

in list3

list5 =

[123,[

'小明'

,'牡丹'],

123]

'小明'

in list5

'小明'

in list5[1]

list5[1]

[1]list3.count(

123)

list3.index(

123)

list3.index(

123,4,

9)list3.reverse(

)list3.sort(

)sort(func,key)

list3.sort(reverse=

true

)list3 = list1 #建立指標

list3 =

list[:

]#拷貝

tuple1 =(1

,2,3

,4,5

,6,7

,8)print

(tuple1)

temp1 =(1

)print

(type

(temp1)

)temp2 =2,

3,4print

(type

(temp2)

)te*** =()

print

(type

(te***)

)temp4 =(1

,)print

(type

(temp4)

)temp5 =1,

print

(type

(temp4)

)temp6 =

('弱音'

,'狂三'

,'蘿莉'

,'光輝'

)temp7 = temp6[:2

]+('洛天依',)

+ temp6[2:

]print

(temp7)

各種函式

手寫數字識別 1

mnist.pkl.gz 先來用乙個神經網路 import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input data mnist input data.read dat...

手寫數字識別

這幾天在想這做字元識別方面的程式,看了很多 但是發現 上的幾乎用處都不是特別的大,理論一大堆,但是用在程式裡面則很難實現,看到有些 上說用連碼法,但是連碼法對結構的變化太敏感了,但是也從一些 裡獲得了一些靈感,我採用的是網格匹配法,準備工作採集樣本,得到了樣本的網格資訊用於接下來的識別,當然也可 一...

手寫數字識別

import os os.environ tf cpp min log level 2 不想讓警告的資訊輸出可以新增 from tensorflow.examples.tutorials.mnist import input data import tensorflow as tf def mnis...