输入“/”快速插入内容

✅Prompt 练习

2023年8月31日修改
https://www.bilibili.com/video/BV1us4y1z73P/?spm_id_from=333.788&vd_source=1322223abc65b2fdc34561f4ee568ce8
因为有些朋友一直问,提前说下访问官网需要梯子😒。
1:张三的提问,gpt帮我改一下卷子
(这个示例是我在ppt中用的到的,并不规范哈)
我是一个英语老师,有个学生天天写错别字,真是神烦,教务处还要求我用红笔修改以下作业,可是我根本懒得改,请帮我批改以下这个学生的英语作业。学生的英语作业是使用三个单引号括起来的部分:
'''
I love speending time in nature.
Whether it'is hiking through they mountains, walking on the beach, or simple sitting in a park, being outdoors makes me feel alive.
There's simething about the fresh air, the sunlight, and the beauty of the naitural world that brings me a senses of peace and contentment
'''
2:程序员小美 需要得到用红笔修改作业的代码
我有一篇英语文章,其中包含着错误。
包含着错误的文章为:
sentence = '''I love speending time in nature. Whether it'is hiking through they mountains, walking on the beach, or simple sitting in a park, being outdoors makes me feel alive. There's simething about the fresh air, the sunlight, and the beauty of the naitural world that brings me a senses of peace and contentment.
'''
修改后正确的文章为:
sentence _right= '''I love spending time in nature. Whether it's hiking through the mountains, walking on the beach, or simply sitting in a park, being outdoors makes me feel alive. There's something about the fresh air, the sunlight, and the beauty of the natural world that brings me a sense of peace and contentment.'''
我需要在一个浏览器上展示错误的文章,文章之中错误的单词被删除线标识,并且错误的单词颜色为红色,最后在错误的单词后面写上正确的单词。
请使用python实现功能并给出代码。
gpt返回代码:
代码块
import re
import webbrowser
# 错误的文章
sentence = '''
I love speending time in nature. Whether it'is hiking through they mountains, walking on the beach, or simple sitting in a park, being outdoors makes me feel alive. There's simething about the fresh air, the sunlight, and the beauty of the naitural world that brings me a senses of peace and contentment.
'''
# 正则表达式,匹配单词字符
word_pattern = re.compile(r'\w+')
# 将错误的文章分割成单词列表
words = word_pattern.findall(sentence)
# 构造HTML标记,将错误单词用删除线标记并且用红色标记出来,并在后面加上正确的单词
marked_sentence = ''
for word in words:
if word.lower() in ['speending', "it'is", 'they', 'simple', 'simething', 'naitural', 'senses']:
correct_word = {
'speending': 'spending',
"it'is": "it's",
'they': 'the',
'simple': 'simply',
'simething': 'something',
'naitural': 'natural',
'senses': 'sense'
}[word.lower()]
marked_sentence += f'<span style="color:red; text-decoration:line-through">{word}</span><span style="color:green">{correct_word}</span> '
else:
marked_sentence += word + ' '
# 构造HTML页面
html = f'''
<html>
<head>
<title>Error Article</title>
</head>
<body>
<p>{marked_sentence}</p>
</body>
</html>
'''
# 写入HTML文件并在浏览器中打开
with open('error_article.html', 'w') as f:
f.write(html)
webbrowser.open('error_article.html')