Michelle Posted March 16, 2021 Share Posted March 16, 2021 Hi all, Love Alfred (v4.3.2 [1221]) but I tried a long time to calculate px to vw with an alfred workflow (before2-3). Script is working but my {query} in the copy to clipboard is always empty. But if I have only one argument and split it, then it is working (after2). But it is a little bit strange, is there a solution with 2 args? Thank yo so much! Link to comment
deanishe Posted March 16, 2021 Share Posted March 16, 2021 It’s very difficult to say what’s wrong with code you can’t run, but you almost certainly don’t want print(). That adds a newline. Either use sys.stdout.write() or from __future__ import print_function and print('%.1f' % result, end='') Link to comment
Michelle Posted March 16, 2021 Author Share Posted March 16, 2021 (edited) Yes I changed it: import sys px, vw = map(float, sys.argv[1].split('/')) result = (px/vw) * 100 if result == int(result): sys.stdout.write('%d' % result) else: sys.stdout.write('%.1f' % result) But still do not know, why I cannot have 2 arguments, it only works with one. Edited March 16, 2021 by Michelle Link to comment
deanishe Posted March 16, 2021 Share Posted March 16, 2021 2 hours ago, Michelle said: why I cannot have 2 arguments, it only works with one What do you mean 2 arguments? Do you mean the fact that the search query from Alfred is always one argument? 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