这些格式说明符是什么意思?

时间:2016-03-14 04:51:50

标签: python

<?php
    require_once('dbconnect.php');
    $today         = date("D M j G:i:s T Y"); //Thu Mar 10 15:11:48 CET 2016
    //$today         = date("Thu Mar 10 15:56:48 CET 2016");
    echo $today. '<br>';
    $explode       = explode(" ", $today);
    $explode_day   = $explode[0];
    $explode_time  = $explode[3];
    $select        = "SELECT id, days, starttime, endtime FROM daytime";
    $execute       = $mysqli->query($select);
    while($row = $execute->fetch_assoc()){
        $days          = $row["days"];
        $starttime     = $row["starttime"];
        $endtime       = $row["endtime"];
        if($days == $explode_day){
           if(strtotime($explode_time) < strtotime($endtime)){
               echo "we were here for you";
           }
           else{
               $nextID        = $row["id"];
               $selectMinId   = "SELECT MIN(id) FROM daytime WHERE id > '$nextID'";
               $minIDExecute  = $mysqli->query($selectMinId);
               $minIdRow      = $minIDExecute->fetch_assoc();
               if($minIdRow['MIN(id)'] == '') {
                   $selectId   = "SELECT MIN(id) FROM daytime WHERE id = '1'";
                   $minID      = $mysqli->query($selectId);
                   $minRow     = $minID->fetch_assoc();
                   $id         = $minRow['MIN(id)'];
               }
               else{
                   $id         = $minIdRow['MIN(id)'];
               }

               $select        = "SELECT id, days, starttime, endtime FROM daytime WHERE id ='$id'";
               $execute       = $mysqli->query($select);
               $row           = $execute->fetch_assoc();
               $days          = $row["days"];
               $starttime     = $row["starttime"];
               if($days == 'Mon'){
                   $weekday    = "Monday";
               }
               else if($days == 'Tue'){
                   $weekday    = "Tuesday";
               }
               else if($days == 'Wed'){
                   $weekday    = "Wednesday";
               }
               else if($days == 'Thu'){
                   $weekday    = "Thursday";
               }
               else if($days == 'Fri'){
                   $weekday    = "Friday";
               }
               else if($days == 'Sat'){
                   $weekday    = "Saturday";
               }
               echo "we are here for you again".' '.$weekday.' '."from".' '.$starttime;
           }
        }
    }

我只想确保print("%c is my %s letter and my number %d number is %.5f"% ("X",'favorite',1,.14)) %c=character%d=digit%f=float,我是对的吗?

1 个答案:

答案 0 :(得分:1)

是的,你是对的。格式规范可以从Python docs找到,以下是相关部分:

'c' - 角色。在打印之前将整数转换为相应的unicode字符 'd' - 十进制整数。输出基数为10的数字 'f' - 定点。将数字显示为定点数。默认精度为6.