我想得到这一栏的文字:
Suzuki music
Chinese music
Conservatory
Blue grass
Rock n roll
Rhythm
Composition
Contra
Instruments
转换为以下格式:
"suzuki music", "chinese music", "conservatory music", "blue grass", "rock n roll", "rhythm"...
这就是我尝试过的:
stuff = [
Suzuki music
Chinese music
Conservatory
Blue grass
Rock n roll
Rhythm
Composition
Contra
Instruments
]
for line in stuff:
list.append("'" + line + "',")
但我有个错误:
文件“/private/var/folders/jv/9\u sy0bn10mbdft1bk9t14qz40000gn/T/Cleanup At Startup/artsplus\u format\u script-393966065.996.py”,第2行 材料=[ ^ 缩进错误:意外缩进 注销
假设您在
input.txt
中有这个:然后这个代码:
将打印您:
您正在寻找^{} 函数
对于您的特定示例,代码如下所示:
使用the ^{} function 和lambda函数可以有效地在
stuff
集合中的每个元素周围加引号。你知道吗相关问题 更多 >
编程相关推荐