在Python中将pbcopy复制到OSX上的剪贴板?

时间:2019-05-25 03:52:58

标签: python python-3.x macos pbcopy

尝试使用pbcopy将输出添加到剪贴板时,出现以下错误。我尝试了该命令的其他变体,但仍然没有运气。 有人对我可能失败的地方有任何想法吗?

错误屏幕截图:

enter image description here

#!/usr/bin/env python3
# This script creates a secure password using all available key combinations.

import secrets , string, os

def prRed(skk): print("\033[91m {}\033[00m" .format(skk))

chars = string.ascii_letters+string.punctuation+string.digits # Cleaner way of assigning variable

print()
pwd_length = int(input('Enter the length of the desired password: '))

print()
print('[+] ' + 'Your secure password is:')
print()

for n in range(1):
    output = ""
    for i in range(pwd_length):
        next_index = secrets.SystemRandom().randrange(len(chars))
        output = output + chars[next_index]
    prRed(os.system("echo '%s' | pbcopy" % output))
print()

0 个答案:

没有答案