试试您的第一个 Claude 提示词!
为了让您预览接下来的内容,我们已经为您准备好了向 Anthropic API 发送请求的 Python 代码。
将任意问题或指令传给 prompt 参数,看看 Claude 会如何回应!
如果一时没有思路,可以先试试下面这些提示词:
- What capabilities make Claude well-suited for enterprise applications?
- Give me two examples of how I could use Claude in a Python app.
本练习是课程的一部分
Claude 模型入门
练习说明
- 将您的提示词输入并替换掉
"INSERT YOUR PROMPT HERE",多做些尝试,准备好后提交您的答案!
交互式实操练习
通过完成这段示例代码来试试这个练习。
from anthropic import Anthropic
client = Anthropic(api_key="datacamp-token", base_url=url)
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=100,
# Enter your prompt
messages=[{"role": "user", "content": "INSERT YOUR PROMPT HERE"}]
)
print(response.content[0].text)