此问题通常是由于使用的Google Sheets API版本无法解析而引起的。解决此问题的方法是确保使用的是正确的API版本,并且在代码中正确地指定了API名称和版本。
以下是一个示例代码,可以通过使用正确的API名称和版本来解决此问题:
import gspread
from google.oauth2.service_account import Credentials
# Replace the API name and version with the correct values
sheet_api = gspread.service_account(filename='credentials.json').client._create_api_client('sheets', 'v4')
# Your code here
在此示例中,我们使用了gspread模块和Google OAuth2服务帐户凭据来创建API客户端。然后,我们使用_create_api_client方法从客户端中获取正确的API名称和版本。在此之后,您可以编写您的代码,并且它应该能够正常运行而没有UnknownApiNameOrVersion错误。