Facebook SDK


Selain itu terdapat beberapa karakter khusus yang dinamakan escape character. Berikut adalah daftar beberapa escape character yang terdapat di Python

Escape Character
Heksadesimal
Keterangan
\a
0x07
bel
\b
0x08
backspace
\f
0x0c
formfeed
\e
0x1b
escape
\n
0x0a
newline
\t
0x09
tab
\v
\r
\nnn
0x0b 0x0d
Vertical tab Carriage return
Notasi oktal, dimana n
Escape Character
Heksadesimal
Keterangan


\xnn

merupakan rentang angka dari 0 sampai 7
Notasi heksadesimal, dimana n merupakan rentang dari 0..9, a..f, atau A..F

Pada kode diatas listing pakai_python_1.py, terdapat sebuah simbol %d di dalam perintah print. Simbol tersebut dinamakan string formatter yang berfungsi untuk mencetak data sesuai dengan format yang diinginkan pada string yang disisipi simbol tersebut. Berikut adalah daftar beberapa string formatter yang disediakan Python:

Simbol
Keterangan
%c
Mencetak karakter
%s
Mencetak    data    dari    jenis    apapun menjadi string
%i, %d
Mencetak angka desimal bertanda
%u
Mencetak angka desimal tak bertanda
%o
Mencetak angka oktal

%x, %X
Mencetak angka heksa dengan huruf kecil, Mencetak angka heksa dengan huruf besar
%f
Mencetak angka real berkoma

%e, %E
Mencetak tanda eksponensial dengan huruf kecil, mencetak tanda eksponensial dengan huruf besar


%g, %G
Fungsi hampir sama dengan %f dan
%e hanya saja pencetakan angka di belakang koma lebih pendek, pencetakan tanda eksponensial menggunakan huruf besar



Kemudian tak lupa kalau di Python sendiri saat sedang menggunakan interpreter prompt,Anda bisa menggunakan function help() untuk melihat struktur sebuah objek atau perintah – perintah di Python. Misal Anda bisa melihat bantuan tentang perintah print maka Anda harus mengetikkan:

>> help('print')

The ``print`` statement

***********************


print_stmt ::= "print" ([expression ("," expression)* [","]]
| ">>" expression [("," expression)+ [","]])

``print`` evaluates each expression in turn and writes the resulting object to standard output (see below). If an object is not a string, it is first converted to a string using the rules for string conversions. The (resulting or original) string is then written. A
space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a
line. This is the case (1) when no characters have yet been written to standard output, (2) when the last character written to standard output is a whitespace character except ``' '``, or (3) when the last write operation on standard output was not a ``print`` statement. (In some cases it may be functional to write an empty string to standard output for this reason.)

Note: Objects which act like file objects but which are not the built-in file objects often do not properly emulate this aspect of the file object's behavior, so it is best not to rely on this.

A ``'\n'`` character is written at the end, unless the ``print``
statement ends with a comma. This is the only action if the statement contains just the keyword ``print``.

Standard output is defined as the file object named ``stdout`` in the built-in module ``sys``. If no such object exists, or if it does not have a ``write()`` method, a ``RuntimeError`` exception is raised.

``print`` also has an extended form, defined by the second portion of the syntax described above. This form is sometimes referred to as "``print`` chevron." In this form, the first expression after the
``>>`` must evaluate to a "file-like" object, specifically an object that has a ``write()`` method as described above. With this extended form, the subsequent expressions are printed to this file object. If the first expression evaluates to ``None``, then ``sys.stdout`` is
used as the file for output. (END)
Untuk keluar dari mode bantuan tersebut tekan tombol “q”. Sekarang kita coba lihat bantuan mengenai struktur data list:
>> help('list')

Help on class list in module builtin :

class list(object)
| list() -> new empty list
| list(iterable) -> new list initialized from iterable's items
|
| Methods defined here:
|
| add (...)
| x. add (y) <==> x+y
|
| contains (...)
| x. contains (y) <==> y in x
|
| delitem (...)
| x. delitem (y) <==> del x[y]
|
| delslice (...)
| x. delslice (i, j) <==> del x[i:j]
| Use of negative indices is not supported.
| eq (...)
:[]
Dengan demikian sekalipun tidak ada koneksi internet, Anda tetap bisa terus membuat program Python dengan dibantu help() yang sudah disediakan oleh Python.

Post a Comment

Previous Post Next Post