set 相关问题

集合是其中没有元素重复的集合,其可以根据排序标准(“有序集合”)枚举其元素或者不保留顺序(“无序集合”)。


为什么我的Python代码不会执行循环选择随机键单词?

import random #allows us to generate random numbers elsewhere in the code set1=[] # creates empty sets print("type genPassword() to initiate the program") def genPassword(): print("Answer the following questions in order. What is your first pet’s name? What is your favorite word? What was your first car? What city/town were you born in? What was the name of your first partner? dont forget to press enter after each word, no spaces.") for c in range(0,5): #allows the user to add elements to the list, each element has to be on a seperate line ele=input() set1.append(ele) print(set1)#displays the current set, currently used for debugging purposes, making sure the code works minlen=int(input("what is the minimum length you would like the password to be?: ")) maxlen=int(input("what is the max length you would like your password to be? (must be more than the shortest word you input in previous section): ")) passlen=0 while minlen >= passlen >= maxlen: set2=[] #empties set 2 amnt = random.randint (1,5) #selects a random number for the anount of keywords to use for f in range(0,amnt): keys=random.sample(set1,1) #selects a random key word set2.append(keys) #adds word to set 2 print(set2)#shows the words it chose set_amnt=len(set2) #how many words in the set iteration=0 string_len=0 for i in range(0,set_amnt): word_len=len(set2[iteration][0]) #takes the length of each word and adds it to the lenght of the whole string iteration=iteration+1 string_len=string_len+word_len print(string_len) #shows how long the string is (how many letters it is total) passlen=string_len

回答 1 投票 0

带pygame set_alpha()设置图像透明度

aohoj, 在Pygame中,我试图设置图像的透明度。 我用这个: ship = pygame.image.load(os.path.join(dir,“ spacehip.png”)) ship.set_alpha(128) 问题: 该代码在MX

回答 2 投票 0

有效的方法是在集合的字典中找到第一次出现元素[闭合]

Given是包含集合的列表的字典。找到集合中元素第一次出现的相应键的有效方法是什么?这应该为所有独特的

回答 0 投票 0









C#设置 /获取控件的属性到 /从另一个线程

... 我有此代码将Controls参数设置为另一个线程:

回答 1 投票 0

如何将多个集合合并为单个std :: set(set union)

在我的案子中,我有一些我想合并的。

回答 3 投票 0

在批处理

我有一个批处理文件,我试图用线路导入文本文件。 我想修改数据以将全部更改为<FS>

回答 0 投票 0


如何使用 Java Stream API 获取嵌套映射值属性的数组

我正在尝试和谷歌搜索,但无法得到正确的结果。如何用流来写这个? 私有最终 ConcurrentMap alleMap = new ConcurrentHashMap<>(1000); 私有字符串[]

回答 2 投票 0

有没有办法在不使用排序函数的情况下对集合进行排序? [重复]

我有一套 设置= {“樱桃”,“香蕉”,“苹果”} 并且通过两行代码,我希望在不使用排序()的情况下对集合进行排序(因为排序()将集合更改为列表)。

回答 1 投票 0

在Python中,有没有办法在不使用排序函数的情况下对Python中的集合进行排序?我不希望将集合转换为列表

我有 set = {"cherry", "banana", "apple"} ,并且有两行代码,我希望不使用sorted() 对集合进行排序,因为sorted() 将集合更改为列表。

回答 1 投票 0

如何将 Set<Set<String>> 转换为 Set<String>?

假设Streams和Collections、Lambdas都可以使用? 我尝试使用 for 循环,但它没有解决我的问题。 // 设置> 到设置 对于(设置...

回答 2 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.