我有 2 个下拉列表,在用户选择列表之一后从列表的字符串返回字符串变量,以及一个处理更新数据到 firestore 的按钮。
这是我创建的变量
String? selectedMonthEnd;
String? selectedYearEnd;
Run Code Online (Sandbox Code Playgroud)
这是2个下拉菜单的代码
final month = [
'January','Febuary','March','April','May','June','July','August','September','October','November','December'];
final year = [
'1900','1901','1902','1903','1904','1905',];
Row(
children: [
//Start Month
Container(
margin: EdgeInsets.only(
top: 4,
bottom: 10,
left: 26,
),
width: 170,
padding:
EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border:
Border.all(color: Colors.grey.shade700, width: 1.2),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: Text(
'Choose Month',
style: TextStyle(
fontSize: 17,
color: Colors.black,
fontWeight: FontWeight.bold),
),
value: selectedMonthStart,
isExpanded: true,
iconSize: 30,
icon: Icon(
Icons.arrow_drop_down,
color: …Run Code Online (Sandbox Code Playgroud) 这是我到目前为止的代码
$dataraw = $_SESSION['image'];
$datagambar = json_encode($dataraw);
echo '<pre>';
print_r($dataraw);
echo '</pre>';
print($escaped_json);
$type1 = gettype($dataraw);
print($type1);
$type2 = gettype($datagambar);
print($type2);
Run Code Online (Sandbox Code Playgroud)
这是$dataraw输出,类型是数组
Array
(
[0] => Array
(
[FileName] => 20221227_202035.jpg
[Model] => SM-A528B
[Longitude] => 106.904251
[Latitude] => -6.167665
)
[1] => Array
(
[FileName] => 20221227_202157.jpg
[Model] => SM-A528B
[Longitude] => 106.9042428
[Latitude] => -6.1676580997222
)
)
Run Code Online (Sandbox Code Playgroud)
这是 $datagambar 输出,类型是字符串
[{"FileName":"20221227_202035.jpg","Model":"SM-A528B","Longitude":106.904251,"Latitude":-6.167665},{"FileName":"20221227_202157.jpg","Model":"SM-A528B","Longitude":106.9042428,"Latitude":-6.167658099722223}]
Run Code Online (Sandbox Code Playgroud)
传递给Python
echo shell_exec("D:\Anaconda\python.exe D:/xampp/htdocs/Klasifikasi_KNN/admin/test.py $datagambar");
Run Code Online (Sandbox Code Playgroud)
这是我的 python test.py
import sys, json
import os
import pymysql
import pandas …Run Code Online (Sandbox Code Playgroud)