Differenze tra le versioni di "Convertire un numero di tipo stringa in un valore di tipo Float con la funzione PyOS string to double() della libreria libpython3.4m"
Da Gambas-it.org - Wikipedia.
|
|
Riga 1: |
Riga 1: |
− | La libreria ''libpython3.4m'' è un interfaccia in C di funzioni appartenenti alle risorse di ''Python''.
| + | #REDIRECT [[Convertire un numero di tipo stringa in un valore di tipo Float con la funzione PyOS string to double() della libreria libpython3]] |
− | | |
− | La funzione ''PyOS_string_to_double( )'' consente di convertire un valore numererico di tipo stringa in un valore di tipo ''Float''.
| |
− | | |
− | Per poter fruire in Gambas di tale funzione esterna, è necessario richiamare la libreria dinamica condivisa: "''libpython3.4m.so.1.0''"
| |
− | | |
− | | |
− | Mostriamo un semplice esempio pratico:
| |
− | Library "libpython3.4m:1.0"
| |
− |
| |
− | <FONT Color=gray>' ''(double) PyOS_string_to_double(const char *str, char **endptr, PyObject *overflow_exception)''
| |
− | ' ''Convert a string s to a double.''</font>
| |
− | Private Extern PyOS_string_to_double(strs As String, endptr As Pointer, overflow_exception As Pointer) As Float
| |
− |
| |
− |
| |
− | '''Public''' Sub Main()
| |
− |
| |
− | Dim f As Float
| |
− |
| |
− | f = PyOS_string_to_double("123.456789", 0, 0)
| |
− |
| |
− | Print f
| |
− |
| |
− | '''End'''
| |
− | | |
− | | |
− | | |
− | | |
− | =Riferimenti=
| |
− | * https://docs.python.org/3.4/c-api/conversion.html?highlight=pyos_string_to_double#c.PyOS_string_to_double
| |
Versione attuale delle 18:10, 28 giu 2022