python类paste()的实例源码

MyDef.py 文件源码 项目:Python-Learning 作者: alicewish 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def WriteClip(info):
    import pyperclip
    pyperclip.copy(info)
    spam = pyperclip.paste()
    return spam


# ================??????================
text_replacer.py 文件源码 项目:100DaysOfCode 作者: pybites 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def paste_from_clipboard():
    text = pyperclip.paste()
    return text
text_replacer.py 文件源码 项目:100DaysOfCode 作者: pybites 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def copy_to_clipboard(new_text):
    pyperclip.copy(new_text)
    print("The new string is now copied to the clipboard. Hit CTRL V to paste.")
reverse_list.py 文件源码 项目:100DaysOfCode 作者: pybites 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def paste_from_clipboard():
    text = pyperclip.paste().split("\r")
    return text
reverse_list.py 文件源码 项目:100DaysOfCode 作者: pybites 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def copy_to_clipboard(new_list):
    new_list[-1] = '\n' + new_list[-1]
    new_text = ''.join(new_list)
    pyperclip.copy(new_text)
    print("The new string is now copied to the clipboard. Hit CTRL V to paste.")
number_sorter.py 文件源码 项目:100DaysOfCode 作者: pybites 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def create_list():
    input_list = pyperclip.paste().split('\n')
    input_list.sort(key=float)
    return input_list
webHandler.py 文件源码 项目:Nancy-VA--MacOS 作者: itz-azhar 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def openMaps(address):
    if address == "":
        address = paste()
    open_new_tab("http://www.google.com/maps/place/"+address)

#open a url in new tab
pyperclip.py 文件源码 项目:blender 作者: gastrodia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
puppetrader_v0.3.5.py 文件源码 项目:puppet 作者: Raytone-D 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_data(self, key='W'):
        "?CVirtualGridCtrl|Custom<n>?????????????????"

        keystroke(self.two_way, ord(key))    # ?????('W')???('E')???('R')
        wait_a_second()    # ?????????...
        op.SendMessageW(self.custom, WM_COMMAND, 57634, self.path_custom[-1])    # background mode

        return pyperclip.paste()
pyperclip.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
main.py 文件源码 项目:myterminal 作者: graktung 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def readChar():
    if event.key == pygame.K_BACKSPACE:
        return 'backspace'
    elif event.key == pygame.K_PAGEUP:
        return 'pageup'
    elif event.key == pygame.K_PAGEDOWN:
        return 'pagedown'
    elif event.key == pygame.K_TAB:
        return 'tab'
    elif event.key == pygame.K_RETURN:
        return 'enter'
    elif event.key == pygame.K_ESCAPE:
        return 'esc'
    elif event.key in (pygame.K_RSHIFT, pygame.K_LSHIFT):
        return 'shift'
    elif event.key in (pygame.K_RCTRL, pygame.K_LCTRL):
        return 'control'
    elif event.key == pygame.K_RIGHT:
        return 'kright'
    elif event.key == pygame.K_LEFT:
        return 'kleft'
    elif event.key == pygame.K_UP:
        return 'kup'
    elif event.key == pygame.K_DOWN:
        return 'kdown'
    elif event.key == pygame.K_CAPSLOCK:
        return None
    elif event.key == 282:
        return 'paste'
    elif event.key == 283:
        return 'begincur'
    elif event.key == 284:
        return 'endcur'
    elif event.key == 285:
        return 'delall'
    else:
        return event.unicode
cmd2.py 文件源码 项目:cmd2 作者: python-cmd2 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _redirect_output(self, statement):
        """Handles output redirection for >, >>, and |.

        :param statement: ParsedString - subclass of str which also contains pyparsing ParseResults instance
        """
        if statement.parsed.pipeTo:
            self.kept_state = Statekeeper(self, ('stdout',))

            # Create a pipe with read and write sides
            read_fd, write_fd = os.pipe()

            # Make sure that self.poutput() expects unicode strings in Python 3 and byte strings in Python 2
            write_mode = 'w'
            read_mode = 'r'
            if six.PY2:
                write_mode = 'wb'
                read_mode = 'rb'

            # Open each side of the pipe and set stdout accordingly
            # noinspection PyTypeChecker
            self.stdout = io.open(write_fd, write_mode)
            # noinspection PyTypeChecker
            subproc_stdin = io.open(read_fd, read_mode)

            # We want Popen to raise an exception if it fails to open the process.  Thus we don't set shell to True.
            try:
                self.pipe_proc = subprocess.Popen(shlex.split(statement.parsed.pipeTo), stdin=subproc_stdin)
            except Exception as ex:
                # Restore stdout to what it was and close the pipe
                self.stdout.close()
                subproc_stdin.close()
                self.pipe_proc = None
                self.kept_state.restore()
                self.kept_state = None

                # Re-raise the exception
                raise ex
        elif statement.parsed.output:
            if (not statement.parsed.outputTo) and (not can_clip):
                raise EnvironmentError('Cannot redirect to paste buffer; install ``xclip`` and re-run to enable')
            self.kept_state = Statekeeper(self, ('stdout',))
            self.kept_sys = Statekeeper(sys, ('stdout',))
            if statement.parsed.outputTo:
                mode = 'w'
                if statement.parsed.output == 2 * self.redirector:
                    mode = 'a'
                sys.stdout = self.stdout = open(os.path.expanduser(statement.parsed.outputTo), mode)
            else:
                sys.stdout = self.stdout = tempfile.TemporaryFile(mode="w+")
                if statement.parsed.output == '>>':
                    self.poutput(get_paste_buffer())


问题


面经


文章

微信
公众号

扫码关注公众号