Каков синтаксис PHP для выходного форматирования Файла/терминала?

Вы можете использовать базовое форматирование строки -

>>> '{:.15f}'.format(df.loc[0,'me'])
>>> '0.094092328767113'

Это приведет к типу данных строки. Кроме того, вы можете преобразовать его в float, если вам нужно использовать numpy as -

>>> np.float64('{:.15f}'.format(df.loc[0,'me']))
>>> 0.094092328767113

. Финальное исправление сводится к обновлению версий Pandas и NumPy, что подтверждается OP в комментариях. .

7
задан Yuval F 30 April 2009 в 11:59
поделиться

1 ответ

Writing command-line PHP scripts is quite simple, actually. You output text in the exact same way you would normally: print and echo both print text to the console. The only difference here is that you can't use HTML tags for formatting, since your code isn't being interpreted by a web browser (i.e. "\n" will actually create a visible line break, not
).

Reading input from stdin is a little trickier, but all it really involves is essentially using some of the file reading functions (e.g. fgets(), fgetc(), fscanf()) and passing in STDIN as the file path (or php://stdin, depending on how new your version of PHP is).

And yes, there is a reference for command-line programming in PHP on php.net. It covers pretty much everything you need to know to work with PHP in a command-line environment.

11
ответ дан 6 December 2019 в 14:09
поделиться
Другие вопросы по тегам:

Похожие вопросы: