python 产生坐标的两种方法

 方法1 用了numpy 库 方法2 用了 random

######  产生随机坐标的方法1
import numpy as np
demo1 = [0,0,1]
demo2 =[0,0,2]
### train
x1=np.arange(800)
y1=np.arange(800)
### test 
x2=np.arange(81,160)

reg1=[]
### the region 1 
for i in range(0,len(x1)+1): 
    for j in range(0,len(y1)+1):
        demo1=[i,j,1]
        reg1.append(demo1) 
reg2=[]
for i in range(0,len(x2)+1): 
    for j in range(0,len(y1)+1):
        demo1=[i,j,1]
        reg2.append(demo1) 
print(len(reg1),len(reg2))





#####产生随机坐标的方法2 
'''
import random
import itertools

random_list_test = list((itertools.product(range(1,500),range(1,100))))
random_list_train= list((itertools.product(range(501,1000),range(1,100))))

print(random_list_test[1],random_list_test[2],type(random_list_test[1]))

for i in  range(0,len(random_list_test)):
      random_list_test[i]=list(random_list_test[i]).append()
      random_list_train[i]=list( random_list_train[i])
print(random_list_test)
print("\n")
print(random_list_train)

print(len(random_list_test))
print(len(random_list_train))
'''


 

你可能感兴趣的:(python)