基本的にはhttps://en.wikipedia.org/wiki/List_of_lists_of_listsのリストをクリップボードにコピーしています。 プログラムを実行すると、各行の前後に行頭文字が追加されます。例えば(Python)クリップボードから文字列を変更する際のヘルプ
:等々
•• Lists of Iranian films ••
そして:
Lists of Iranian films
がに変換します。このプログラムは、行の前に箇条書きを追加するときに機能しますが、後ろに置くと改行文字なしの長い文字列が1つだけ表示されます。誰かが私に間違っていることを教えてもらえますか?
ここでは、コードです:私のクリップボードに
#bulletPointAdder.py - Adds Wikipedia bullet points to the start and end
#of each line of text on the clipboard
import pyperclip
text=pyperclip.paste() #paste a big string of text from clipboard into the 'text' string
# Separate lines and add stars
lines = text.split('\n') #'lines' contains a list of all the individual lines up until '\n'
#lines= ['list of iserael films', 'list of italian films' ...]
for i in range(len(lines)): #loop through all indexes in the "lines" list
lines[i] = '••' + lines[i] + '••' #add bullets before and after each line
text = '\n'.join(lines) #put a '\n' in between the list members (joins them) into a single string
pyperclip.copy(text)
:メモ帳に貼り付け
List of Israeli films before 1960
List of Israeli films of the 1960s
List of Israeli films of the 1970s
List of Israeli films of the 1980s
がクリップボード:
••List of Israeli films before 1960••••List of Israeli films of the 1960s••••List of Israeli films of the 1970s••••List of Israeli films of the 1980s••
あなたの質問がありますか? 'text'の種類は何ですか? 'str'要素の' list'ですか? – blacksite
申し訳ありませんが、タイプはクリップボードにコピーされた文字列です。 – tadm123