本文整理匯總了Python中clipboard.copy方法的典型用法代碼示例。如果您正苦於以下問題:Python clipboard.copy方法的具體用法?Python clipboard.copy怎麽用?Python clipboard.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類clipboard
的用法示例。
在下文中一共展示了clipboard.copy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: printShortener
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def printShortener(shortener, url):
#print "\n\tinside print."
try:
getshorted = shortener.short(url)
print "\n\tShortened url is {}".format(getshorted)
clipboard.copy(getshorted)
print "\n\tDone, your shortened url is on clipboard.!"
print "\n\tLaunch your browser and use 'Command-V' OR 'Ctrl + V' to paste the link in your browser."
time.sleep(5)
print "\n\tWant to Fetch QRCode? press 1 else press 0"
choice=int(input("\n\t"))
if choice == 1:
getQRCode(shortener,url)
elif choice == 0:
return
else:
print "Error!"
return
except Exception as e:
print str(e)
示例2: getQRCode
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def getQRCode(shortener, url):
shortener.short(url)
print "\n\tQRCode is on the URL: {}".format(shortener.qrcode())
try:
webbrowser.open_new_tab(shortener.qrcode())
time.sleep(2)
except Exception as e:
print "\n\tLaunch your browser and use 'Command-V' OR 'Ctrl + V' to paste the link in your browser."
clipboard.copy(shortener.short(url))
time.sleep(2)
#you could also save your qrcode locally by simply calling urllib on the image url
#----------------------- MAIN FUNCTIONS --------------------
示例3: tinyurlShortener
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def tinyurlShortener(url):
shortened = tinyurl.create_one(url)
print "\n\tShortened url is {}".format(shortened)
clipboard.copy(shortened)
print "\n\tDone, your shortened url is on clipboard.!"
print "\n\tLaunch your browser and use 'Command-V' OR 'Ctrl + V' to paste the link in your browser."
time.sleep(5)
print "\n\tWant to Fetch QRCode? press 1 else press 0"
choice=int(input("\n\t"))
if choice == 1:
getOnlyQRCode(shortened)
elif choice == 0:
return
else:
print "Error!"
return
示例4: isgdShortener
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def isgdShortener(tourl):
url = 'https://is.gd/create.php?format=simple&url={}'.format(tourl)
shortened = urllib2.urlopen(url).read()
print "\n\tShortened url is {}".format(shortened)
clipboard.copy(shortened)
print "\n\tDone, your shortened url is on clipboard.!"
print "\n\tLaunch your browser and use 'Command-V' OR 'Ctrl + V' to paste the link in your browser."
time.sleep(5)
print "\n\tWant to Fetch QRCode? press 1 else press 0"
choice=int(input("\n\t"))
if choice == 1:
getOnlyQRCode(shortened)
elif choice == 0:
return
else:
print "Error!"
return
示例5: _create_popup_menu
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def _create_popup_menu(self, widget=None):
if widget is None: widget = self.widget
menu = misc.wxGladePopupMenu(self.name)
i = misc.append_menu_item(menu, -1, _('Remove Panel\tDel'), wx.ART_DELETE)
misc.bind_menu_item_after(widget, i, self.remove)
i = misc.append_menu_item(menu, -1, _('Copy\tCtrl+C'), wx.ART_COPY)
misc.bind_menu_item_after(widget, i, clipboard.copy, self)
i = misc.append_menu_item(menu, -1, _('Cut\tCtrl+X'), wx.ART_CUT)
misc.bind_menu_item_after(widget, i, clipboard.cut, self)
i = misc.append_menu_item(menu, -1, _('Paste Sizer\tCtrl+V'), wx.ART_PASTE)
misc.bind_menu_item_after(widget, i, clipboard.paste, self)
if self.children or not clipboard.check("sizer"): i.Enable(False)
menu.AppendSeparator()
if hasattr(self.parent, "_add_parent_popup_menu_items"):
self.parent._add_parent_popup_menu_items(menu, self, widget)
i = misc.append_menu_item(menu, -1, _('Preview'))
misc.bind_menu_item_after(widget, i, self.preview_parent)
return menu
示例6: colarAreaTransf
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def colarAreaTransf(string):
clipboard.copy(string)
示例7: copy_current_address
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def copy_current_address():
start, end = sark.get_selection()
clipboard.copy("0x{:08X}".format(start))
示例8: copy_current_file_offset
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def copy_current_file_offset():
"""Get the file-offset mapped to the current address."""
start, end = sark.get_selection()
try:
file_offset = sark.core.get_fileregion_offset(start)
clipboard.copy("0x{:08X}".format(file_offset))
except sark.exceptions.NoFileOffset:
message("The current address cannot be mapped to a valid offset of the input file.")
示例9: copy_current_selection
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def copy_current_selection():
start, end = sark.get_selection()
buffer = sark.data.read_memory(start, end)
clipboard.copy(to_hex_bytes(buffer))
示例10: get_bookmarklist
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def get_bookmarklist(bookId, headers):
"""獲取某本書的筆記返回md文本"""
url = "https://i.weread.qq.com/book/bookmarklist"
params = dict(bookId=bookId)
r = requests.get(url, params=params, headers=headers, verify=False)
if r.ok:
data = r.json()
# clipboard.copy(json.dumps(data, indent=4, sort_keys=True))
else:
raise Exception(r.text)
chapters = {c['chapterUid']: c['title'] for c in data['chapters']}
contents = defaultdict(list)
for item in sorted(data['updated'], key=lambda x: x['chapterUid']):
# for item in data['updated']:
chapter = item['chapterUid']
text = item['markText']
create_time = item["createTime"]
start = int(item['range'].split('-')[0])
contents[chapter].append((start, text))
chapters_map = {title: level for level, title in get_chapters(int(bookId), headers)}
res = ''
for c in sorted(chapters.keys()):
title = chapters[c]
res += '#' * chapters_map[title] + ' ' + title + '\n'
for start, text in sorted(contents[c], key=lambda e: e[0]):
res += '> ' + text.strip() + '\n\n'
res += '\n'
return res
示例11: get_bestbookmarks
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def get_bestbookmarks(bookId, headers):
"""獲取書籍的熱門劃線,返回文本"""
url = "https://i.weread.qq.com/book/bestbookmarks"
params = dict(bookId=bookId)
r = requests.get(url, params=params, headers=headers, verify=False)
if r.ok:
data = r.json()
# clipboard.copy(json.dumps(data, indent=4, sort_keys=True))
else:
raise Exception(r.text)
chapters = {c['chapterUid']: c['title'] for c in data['chapters']}
contents = defaultdict(list)
for item in data['items']:
chapter = item['chapterUid']
text = item['markText']
contents[chapter].append(text)
chapters_map = {title: level for level, title in get_chapters(int(bookId))}
res = ''
for c in chapters:
title = chapters[c]
res += '#' * chapters_map[title] + ' ' + title + '\n'
for text in contents[c]:
res += '> ' + text.strip() + '\n\n'
res += '\n'
return res
示例12: get_chapters
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def get_chapters(bookId, headers):
"""獲取書的目錄"""
url = "https://i.weread.qq.com/book/chapterInfos"
data = '{"bookIds":["%d"],"synckeys":[0]}' % bookId
r = requests.post(url, data=data, headers=headers, verify=False)
if r.ok:
data = r.json()
clipboard.copy(json.dumps(data, indent=4, sort_keys=True))
else:
raise Exception(r.text)
chapters = []
for item in data['data'][0]['updated']:
if 'anchors' in item:
chapters.append((item.get('level', 1), item['title']))
for ac in item['anchors']:
chapters.append((ac['level'], ac['title']))
elif 'level' in item:
chapters.append((item.get('level', 1), item['title']))
else:
chapters.append((1, item['title']))
return chapters
示例13: ee_auth_entry
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def ee_auth_entry():
auth_url = ee.oauth.get_authorization_url()
clipboard.copy(auth_url)
print("Authentication link copied: Go to browser and click paste")
time.sleep(10)
print("Enter your GEE API Token")
password = str(getpass.getpass())
auth_code = str(password)
token = ee.oauth.request_token(auth_code)
ee.oauth.write_token(token)
print("\nSuccessfully saved authorization token.")
示例14: main
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def main():
print "\n\tList of URL Shortener Services:\n\t\t1. Google\n\t\t2. Bit.ly\n\t\t3. TinyURL\n\t\t4. IS.GD\n\t\t"
try:
choice = int(raw_input("\n\tChoose URL SHORTENER service: "))
print "\n\tTo enter url, you can type manually in your console or else you can copy the url using 'Command-V' or 'Ctrl + V'\n\tfrom browser."
print "\n\t1. Manually in console\n\t2. Copy from browser\t"
urlchoice = int(raw_input("\n\tEnter choice: "))
if urlchoice == 1:
print "\n\tEnter url to be shortened: ",
url = str(raw_input(""))
elif urlchoice == 2:
print "\tYou have five seconds..copy the url from address bar you wish to shorten!"
time.sleep(5)
url = clipboard.paste()
else:
print "\n\tInvalid Option.! Quitting.."
time.sleep(1)
sys.exit(0)
if choice == 1:
googleShortener(url)
elif choice == 2:
bitlyShortener(url)
elif choice == 3:
tinyurlShortener(url)
elif choice == 4:
isgdShortener(url)
else:
print "Invalid Service."
except Exception as e:
print str(e)
示例15: gcs_cred
# 需要導入模塊: import clipboard [as 別名]
# 或者: from clipboard import copy [as 別名]
def gcs_cred(cred):
with open (cred) as file:
aoi_resp=json.load(file)
filestr=json.dumps(aoi_resp)
print('')
bstr = filestr.encode('utf-8')
try:
clipboard.copy(base64.b64encode(bstr).decode('ascii'))
print('base64 encoding copied to clipboard')
except Exception as e:
print('Unable to copy to clipboard'+'\n')
print(base64.b64encode(bstr).decode('ascii'))