本帖最后由 Randy666 于 2020-11-25 18:23 编辑
在网上复制了一段代码到VS STUDIO里,结果点了run以后没有反应。。不知道该怎么搞
代码如下:
'''
import itchat
enableCmdQR=True
hotReload=True
itchat.auto_login(enableCmdQR=True,hotReload=True)
to_name = itchat.search_friends(name="哆啦A梦")
print(to_name)
# # 发送文本消息
for i in range(10):
itchat.send('测试中。。。',toUserName=to_name[0]['UserName'])
#
# # 发送表情包
file_img = 'biaoqingbao.jpg'
itchat.send_image(file_img,toUserName=to_name[0]['UserName'])
from itchat.content import *
# 判断收到的信息类型,如果收到的信息是文本,则执行下面的函数
@itchat.msg_register(TEXT)
def text_reply(msg):
print(msg.text)
reply_text = msg.text.replace('吗?','!')
print(reply_text)
return reply_text
itchat.msg_register([PICTURE,RECORDING,ATTACHMENT,VIDEO])
def download_files(msg):
print(msg)
msg.download(msg.fileName)
itchat.auto_login(enableCmdQR=True,hotReload=True)
# 保证程序一直在运行
itchat.run()
import os
import time
import xlrd
import itchat
itchat.auto_login(enableCmdQR=True,hotReload=True)
change_time_save = time.ctime(os.stat('aaa.xlsx').st_mtime)
while True:
time.sleep(5)
change_time = time.ctime(os.stat('aaa.xlsx').st_mtime)
if change_time_save == change_time:
pass
else:
change_time_save = change_time
xlsx = xlrd.open_workbook('aaa.xlsx')
table = xlsx.sheet_by_index(0)
content = str(table.cell_value(0,0))
to_name = itchat.search_friends(name='微信好友备注名')
itchat.send(content,toUserName=to_name[0]['UserName'])
print("发送成功!时间:" + time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())) run之后变成这样了: [Running] python -u "c:\Users\Gover\Desktop\Randy\app.py"
[Done] exited with code=0 in 0.192 seconds
|