Pelokalan
Python ID
id en
Masuk
Proyek
c-api__arg.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
The first three of these functions described, :c:func:`PyArg_ParseTuple`, :c:func:`PyArg_ParseTupleAndKeywords`, and :c:func:`PyArg_Parse`, all use *format strings* which are used to tell the function about the expected arguments. The format strings use the same syntax for each of these functions.
Tiga fungsi pertama dijelaskan yaitu, :c:func:`PyArg_ParseTuple`, :c:func:`PyArg_ParseTupleAndKeywords`, dan :c:func:`PyArg_Parse`, semuanya menggunakan *format string* yang digunakan untuk memberitahu fungsi tentang expected argumen . Format string menggunakan sintaks yang sama untuk setiap fungsi tersebut.
This variant on ``s`` is used for encoding Unicode into a character buffer. It only works for encoded data without embedded NUL bytes.
Ten wariant ``s`` jest używany do zakodowania Unicode w buforze znaków. To działa tylko dla zakodowanych danych bez osadzonych znaków NUL.
This format requires two arguments. The first is only used as input, and must be a :c:expr:`const char*` which points to the name of an encoding as a NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used. An exception is raised if the named encoding is not known to Python. The second argument must be a :c:expr:`char**`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument.
Format ini membutuhkan dua argumen. Yang pertama hanya digunakan sebagai masukan, dan harus berupa :c:expr:`const char*` yang menunjuk pada nama pengkodean sebagai string yang diakhiri dengan NUL, atau ``NULL``, dalam hal ini pengkodean ``'utf-8'`` yang digunakan. Pengecualian akan muncul jika pengkodean yang disebutkan tidak dikenal oleh Python. Argumen kedua harus berupa :c:expr:`char**`; nilai pointer yang direferensikan akan diset ke buffer dengan isi teks argumen. Teks akan dikodekan dalam pengkodean yang ditentukan oleh argumen pertama.
This variant on ``s#`` is used for encoding Unicode into a character buffer. Unlike the ``es`` format, this variant allows input data which contains NUL characters.
Ten wariant ``s#`` używany jest do kodowania Unicode w buforze znaków. W przeciwieństwie do formatu ``es``, ten wariant pozwala wprowadzać dane zawierające znaki NUL.
It requires three arguments. The first is only used as input, and must be a :c:expr:`const char*` which points to the name of an encoding as a NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used. An exception is raised if the named encoding is not known to Python. The second argument must be a :c:expr:`char**`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument. The third argument must be a pointer to an integer; the referenced integer will be set to the number of bytes in the output buffer.
Ini membutuhkan tiga argumen. Yang pertama hanya digunakan sebagai masukan, dan harus berupa :c:expr:`const char*` yang menunjuk pada nama pengkodean sebagai string yang diakhiri dengan NUL, atau ``NULL``, dalam hal ini pengkodean ``'utf-8'`` yang digunakan. Pengecualian akan muncul jika pengkodean yang disebutkan tidak dikenal oleh Python. Argumen kedua harus berupa :c:expr:`char**`; nilai pointer yang direferensikan akan disetel ke buffer dengan isi teks argumen. Teks akan dikodekan dalam pengkodean yang ditentukan oleh argumen pertama. Argumen ketiga harus berupa penunjuk ke sebuah bilangan bulat; bilangan bulat yang direferensikan akan diset ke jumlah byte dalam buffer keluaran.
``u``, ``u#``, ``Z``, and ``Z#`` are removed because they used a legacy ``Py_UNICODE*`` representation.
``u``, ``u#``,``Z``, dan ``Z#`` dihapus karena menggunakan representasi ``Py_UNICODE*``.
The list of format units ends here; the string after the colon is used as the function name in error messages (the "associated value" of the exception that :c:func:`PyArg_ParseTuple` raises).
The list of format units ends here; the string after the semicolon is used as the error message *instead* of the default error message. ``:`` and ``;`` mutually exclude each other.
Na tym kończy się lista jednostek formatu; ciąg po średniku jest traktowany jako informacja o błędzie do użycia *zamiast* automatycznej wiadomości o błędzie. Znaki dwukropka ``:`` i średnika ``;`` wzajemnie się wykluczają.
Additional arguments passed to these functions must be addresses of variables whose type is determined by the format string; these are used to store values from the input tuple. There are a few cases, as described in the list of format units above, where these parameters are used as input values; they should match what is specified for the corresponding format unit in that case.
Dodatkowe parametry przekazywane do tych funkcji muszą być adresami zmiennych których typ jest określany przez ciąg formatu; są one używane do przechowywania wartości z krotki wejściowej. Jest parę przypadków, jak opisuje to lista jednostek formatu powyżej, gdzie te parametry są używane jako wprowadzane wartości; w takich przypadku powinny one odpowiadać temu, co jest określone we właściwych im jednostach formatu.
Ensure that the keys in the keywords argument dictionary are strings. This is only needed if :c:func:`PyArg_ParseTupleAndKeywords` is not used, since the latter already does this check.
The characters space, tab, colon and comma are ignored in format strings (but not within format units such as ``s#``). This can be used to make long format strings a tad more readable.
Convert a null-terminated C string to a Python :class:`str` object using ``'utf-8'`` encoding. If the C string pointer is ``NULL``, ``None`` is used.
Pass a Python object untouched but create a new :term:`strong reference` to it (i.e. its reference count is incremented by one). If the object passed in is a ``NULL`` pointer, it is assumed that this was caused because the call producing the argument found an error and set an exception. Therefore, :c:func:`Py_BuildValue` will return ``NULL`` but won't raise an exception. If no exception has been raised yet, :exc:`SystemError` is set.
Mengoper objek Python tanpa disentuh tetapi membuat :term:`referensi kuat` baru ke objek tersebut (misalnya, jumlah referensinya bertambah satu). Jika objek yang dioper adalah sebuah penunjuk ``NULL``, diasumsikan bahwa hal ini disebabkan karena pemanggilan yang menghasilkan argumen tersebut menemukan kesalahan dan membuat pengecualian. Oleh karena itu, :c:func:`Py_BuildValue` akan mengembalikan ``NULL`` tetapi tidak akan memunculkan pengecualian. Jika tidak ada pengecualian yang dibangkitkan, :exc:`SystemError` akan di-set.