在Python中,我可以将变量声明为d ='/some/dir/%s'
,然后将%s
替换为任何值
>>> d = '/some/dir/%s'
>>> d % "hello"
'/some/dir/hello'
是否可以在Go中执行相同的操作?如果是这样,怎么样?
答案 0 :(得分:2)
是的,fmt.Sprintf
会这样做:
$location= '1';
echo "<pre>";
$sql="SELECT name from IFC,tables
WHERE IFC.tablename=tables.id AND IFC.location=:location
ORDER BY Numopinions DESC
";
$stmt= $dbh->prepare($sql);
$stmt->bindParam(":location", $location);
if($stmt->execute())
{
$rows = $stmt-> fetchAll();
print_r($rows);
}