Logo Pic

如何用python批量生成红菇属物种


注意:作者还没有写完这篇文章。

但是可以先偷看几眼(`∇´):
import random

def random_russula_structure():
    shortgills = ['shortgills-present','shortgills-absent']
    gills = ['free', 'adnexed', 'adnate', 'decurrent']
    spore_print = ['white', 'cream', 'buff', 'yellow', 'brown', 'somewhat-orangish']
    odour = ['not-distinctive', 'pleasant', 'fruty', 'foul', '']
    taste = ['not-distinctive', 'acrid', 'mild', 'bitter']
    return ['Gill attatchment:' + str(random.choice(gills)), 'Shortgills:' + str(random.choice(shortgills)), 'Spore print color:' + str(random.choice(spore_print)), 'Taste:' + str(random.choice(taste))]


def random_russula_ecology():
    ecology = ['ectomycorrhizal with hardwoods', 'ectomycorrhizal with conifers']
    growth = ['solitary', 'scattered', 'gregarious']
    return ['Habitat:' + str(random.choice(ecology)), 'Growth:' + str(random.choice(growth))]


for i in range(10):
    scientific_name = 'Russula sp.' + str(i)
    print (scientific_name)
    randcolor = str(random.randint(0,255)) + ',' + str(random.randint(0,255)) + ',' + str(random.randint(0,255))
    color = 'Color (RGB):' + randcolor
    print (color)
    randstructure = random_russula_structure()
    structure = 'Structure:' + str(randstructure)
    print (structure)
    randecology = random_russula_ecology()
    mushroomecology = 'Ecology:' + str(randecology)
    print (mushroomecology)

(正文完)


发表时间:2023-06-12

历史版本:1

上次编辑:2023-06-12