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)
#複製新的字符串