DickDi Posted May 26, 2019 Share Posted May 26, 2019 Hello,everybody! I want to implement a very simple function by workflow. First, type the keyword as a trigger and a number (for example decimal 23.45678) as a query. Then, convert it to 23.46(keep two decimal places). Finally, copy the consequence to the clipboard. It seems a really easy job. But I don’t know how the query or arguments input and output through python. After searching answers for several hours, I can’t find similar demos from internet. It makes me a little depressed. Could anybody do me a favor? Thanks so much! Link to comment
vitor Posted May 27, 2019 Share Posted May 27, 2019 Welcome @DickDi, Why python, can’t it be any language? Here’s a Workflow that does what you ask, in ruby. Link to comment
DickDi Posted May 27, 2019 Author Share Posted May 27, 2019 1 hour ago, vitor said: Welcome @DickDi, Why python, can’t it be any language? Here’s a Workflow that does what you ask, in ruby. It works! Thank you~~~😉 Sometimes Python seems to be more friendly than other language. And I prepare to rewrite the workflow for some other functions(easy calculations), hmm~~~😁 Link to comment
amoose136 Posted May 29, 2019 Share Posted May 29, 2019 from __future__ import print_function print('{:.2f}'.format(42.022345545456)) Will return 42.02 You could you pyperclip to write to the clipboard or pass the object along to the Alfred clipboard object. Dean Jackson's Alfred-Workflow library can handle the interface with Alfred if you need more complexity. Link to comment
DickDi Posted June 1, 2019 Author Share Posted June 1, 2019 On 5/30/2019 at 5:50 AM, amoose136 said: from __future__ import print_function print('{:.2f}'.format(42.022345545456)) Will return 42.02 You could you pyperclip to write to the clipboard or pass the object along to the Alfred clipboard object. Dean Jackson's Alfred-Workflow library can handle the interface with Alfred if you need more complexity. Thanks so much ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now