生成字符串[名称]和数字[ID]以添加到集合中

时间:2019-05-01 17:45:43

标签: python-3.x string random

要求: 系统中类别的总数不超过100。 类别名称在系统中所有现有类别中都是唯一的。

在我的测试中,我正在考虑执行最多101条记录的POST,并且期望在 第101次尝试。

正在寻求:  Python中是否有内置功能可以生成 唯一的名称和ID?任何代码段/实现都将有所帮助。

这是伪代码。

While length of collection is <= 101:
  randomly generate [unique name] and [id] # This is to be passed to 
  PAYLOAD before POST
  PAYLOAD = {'id': ID, 'name': Name}
  response = requests.post(url=API_ENDPOINT, data=json.dumps(PAYLOAD), headers=HEADERS)

0 个答案:

没有答案