Python prints tabular data, leaves the correct spaces, and formats the typed
The code is as follows:
def printpicnic (itemsdict,leftwidth,rightwidth):
Print (' PICNIC ITEMS '. Center (leftwidth + rightwidth, '-'))
For k,v in Itemsdict.items ():
Print (K.ljust (leftwidth, '. ') +str (v). Rjust (Rightwidth))
Picnicitems = {' Sandwitches ': 4, ' apple ': +, ' cups ': 4, ' Cookies ': 8000}
Printpicnic (picnicitems,12,5)
Printpicnic (picnicitems,20,6)
The effect is as follows:
Paragraph asterisk or comment, when you edit a Wikipedia article, you can create an unordered list, each of which occupies one row and an asterisk in front of it. This can be added manually, but when you have a very large list, you want to add asterisks to the front.
You can automate this task with a small Python script
So the following things need to be done:
1. Pasting text from the Clipboard
2. Do some processing on it
3. Copy the new text to the Clipboard
So the prototype is like this:
Import Pyperclip
Text = Pyperclip.paste ()
#TODO: Seperate lines and add stars
Pyperclip.copy (text)
So the part that needs to be done is to split the string into a list and then add an asterisk to each element of the list and then join the string again.
The complete code is as follows:
Import Pyperclip
Text = Pyperclip.paste ()
lines = Text.split (' \ n ')
For I in range (len (lines)):
Lines[i] = ' # ' + lines[i]
Text = ' \ n '. Join (lines)
Pyperclip.copy (text)
Python prints tabular data, leaving the correct spaces and paragraph asterisks or notes