python實現最簡單小遊戲和簡單圖像信息獲取

廢話不多說,下面可以提供一個適合新手小白的遊戲代碼段:

<code>print('------I lve reading IP 搬磚工文章------')
temp = input("guess what the number of IPbanzhuangong thinking:")
guess = int(temp)
if guess == 3:
print("you are right!but no fish for u")
else:
print("wrong!finished")/<code>


圖像處理過程中,常需要獲取圖像的RGB值等信息,Linux下面運行的代碼示例:

<code>import cv2 as cv

def get_image_info(image):

print(type(image))

print(image.shape)

print(image.size)

print(image.dtype)

print('---------hello python---------')

src = cv.imread('/desk//23-1.png')

cv.namedWindow('input image', cv.WINDOW_AUTOSIZE)

cv.imshow('input image', src)

get_image_info(src)

cv.waitKey(0)



cv.destroyAllwindows()/<code>

輸出的示例如下:


python實現最簡單小遊戲和簡單圖像信息獲取

運行結果


分享到:


相關文章: