""" 什么是编程?这就是编程! """ __author__ = '李兴球' __blog__ = 'www.lixingqiu.com' __date__ = '2020/5/10' import sys import time import os.path import win32clipboard as w import win32con import win32api import pyautogui def getText(): """读取剪贴板""" w.OpenClipboard() d = w.GetClipboardData(win32con.CF_TEXT) w.CloseClipboard() return d def setText(aString): """写入剪贴板""" w.OpenClipboard() w.EmptyClipboard() w.SetClipboardText(aString) w.CloseClipboard() if __name__=='__main__': self = "E:\\Python\\sprites\\001_最简弹球\\最简弹球.py" f = open(self,encoding='utf-8') filecontent = f.read() f.close() win32api.ShellExecute(0, 'open', 'notepad.exe', 'C:\\Users\\Administrator\\Desktop\\最简弹球.py','',1) time.sleep(2) for char in filecontent: setText(char) if char=='\n': pyautogui.hotkey('enter') else: pyautogui.hotkey('ctrl', 'v') time.sleep(0.02) # 程序编写完毕,你明白什么是编程了吗?
李兴球
李兴球的博客是Python创意编程原创博客