

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# DeleteLexicon
<a name="DeleteLexiconPython"></a>

次の Python コード例は、ローカルの AWS 設定で指定したリージョンのレキシコンを削除するのに AWS SDK for Python (Boto) を使用します。例では、指定したレキシコンのみを削除します。実際にレキシコンを削除する前に、処理を進めることを確認するよう求めます。

次のコード例では、AWS SDK の設定ファイルに保存してあるデフォルトの認証情報を使用します。設定ファイルを作成する方法については、「[のセットアップAWS CLI](setup-cli.md)」を参照してください。

このオペレーションの詳細については、[https://docs.aws.amazon.com/polly/latest/dg/API_DeleteLexicon.html](https://docs.aws.amazon.com/polly/latest/dg/API_DeleteLexicon.html) API リファレンスを参照してください。

```
from argparse import ArgumentParser
from sys import version_info

from boto3 import Session
from botocore.exceptions import BotoCoreError, ClientError


# Define and parse the command line arguments
cli = ArgumentParser(description="DeleteLexicon example")
cli.add_argument("name", type=str, metavar="LEXICON_NAME")
arguments = cli.parse_args()

# Create a client using the credentials and region defined in the adminuser
# section of the AWS credentials and configuration files
session = Session(profile_name="adminuser")
polly = session.client("polly")

# Request confirmation
prompt = input if version_info >= (3, 0) else raw_input
proceed = prompt((u"This will delete the \"{0}\" lexicon,"
                  " do you want to proceed? [y,n]: ").format(arguments.name))

if proceed in ("y", "Y"):
    print(u"Deleting {0}...".format(arguments.name))

    try:
        # Request deletion of a lexicon by name
        response = polly.delete_lexicon(Name=arguments.name)
    except (BotoCoreError, ClientError) as error:
        # The service returned an error, exit gracefully
        cli.error(error)

    print("Done.")
else:
    print("Cancelled.")
```