php案例:提交的内容形成了标签

简介: php案例:提交的内容形成了标签

前言

php提交的内容形成了标签

二、使用步骤

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="./cyg.php" method="POST">
    <input type="text" name="tag" />
    <input type="submit" value="提交">
</form>
</body>
</html>
<?php
$colors = array('red', 'blue', 'green', 'yellow');
$randomColor = $colors[array_rand($colors)];//随机产生标签的颜色
echo '<span style="background-color: ' . $randomColor . ';" class="tag">' . $_POST['tag'] . '</span>';//获取到表单数据输出

2.读入数据

代码如下(示例):

data = pd.read_csv(
    'https://labfile.oss.aliyuncs.com/courses/1283/adult.data.csv')
print(data.head())

该处使用的url网络请求的数据。


效果



相关文章
|
4月前
|
网络协议 PHP