从未组织的单词列表中组织以逗号分隔的单词列表(仅在可能时提供提示)

Organize a List of Words Separated by Comma from Unorganized List of Words (TIPS ONLY IF POSSIBLE)

基本上,我有一长串单词(在下面提供),我想使用 Python 来组织这些单词。问题是单词列表还没有逗号+它们由换行符分隔,大约有 200 个。退格两次并为每个单词添加一个逗号似乎有点乏味,我相信在 Python 中有一些方法可以自动执行此操作。不过我是初学者,实在想不出方法。

如果可能的话,我正在找人为我指出正确的方向来解决这个问题,因为我真的很想自己弄清楚(大部分情况下,哈哈)。

我希望它看起来像这样:

[Adventurous, Aggressive, Agreeable, Alert, Alive, Amused] 

(以此类推)


当我 copy/paste 它时,单词列表是这样的:

adorable

adventurous

aggressive

agreeable

alert

alive

amused

angry

annoyed

annoying

anxious

arrogant

ashamed

attractive

average

awful

bad

beautiful

better

bewildered

black

bloody

blue

blue-eyed

blushing

bored

brainy

brave

breakable

bright

busy

calm

careful

cautious

charming

cheerful

clean

clear

clever

cloudy

clumsy

colorful

combative

comfortable

concerned

condemned

confused

cooperative

courageous

crazy

creepy

crowded

cruel

curious

cute

dangerous

dark

dead

defeated

defiant

delightful

depressed

determined

different

difficult

disgusted

distinct

disturbed

dizzy

doubtful

drab

dull

您可以使用 tkinter 模块从剪贴板中获取复制的文本,然后 split 换行符上的文本 \n 最后 filter 任何项目空字符串。

import tkinter as tk
root = tk.Tk()
text = root.clipboard_get()
list(filter(lambda x: x != '', text.split('\n')))

输出:

['adventurous', 'aggressive', 'agreeable', 'alert', 'alive', 'amused', 'angry', 'annoyed', 'annoying', 'anxious', 'arrogant', 'ashamed', 'attractive', 'average', 'awful', 'bad', 'beautiful', 'better', 'bewildered', 'black', 'bloody', 'blue', 'blue-eyed', 'blushing', 'bored', 'brainy', 'brave', 'breakable', 'bright', 'busy', 'calm', 'careful', 'cautious', 'charming', 'cheerful', 'clean', 'clear', 'clever', 'cloudy', 'clumsy', 'colorful', 'combative', 'comfortable', 'concerned', 'condemned', 'confused', 'cooperative', 'courageous', 'crazy', 'creepy', 'crowded', 'cruel', 'curious', 'cute', 'dangerous', 'dark', 'dead', 'defeated', 'defiant', 'delightful', 'depressed', 'determined', 'different', 'difficult', 'disgusted', 'distinct', 'disturbed', 'dizzy', 'doubtful', 'drab', 'dull']