Python 在 Wiki 标记中添加无序列表

Python编程快速上手实践项目题目,欢迎指证与优化!
代码:

#! python3
# bulletPointAdder.py - Adds Wikipedia bullet points to the start
# of each line of text on the clipboard.

import pyperclip
text = pyperclip.paste()
# 从剪贴板粘贴文本
lines = text.split('\n')
# 使用 split()方法得到一个字符串的列表,以回车符分隔
for i in range(len(lines)):
    lines[i] = '* ' + lines[i] 
    #遍历 lines 中的每个表项,在每个表项前加*
text = '\n'.join(lines)
#指定字符\n连接序列中元素后生成的新字符串
pyperclip.copy(text)
#复制新的字符串

猜你喜欢

转载自blog.51cto.com/xxy12345/2425718