我需要用
导入<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="2"
android:orientation="vertical"
android:background="@color/colorPrimary"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:layout_height="170dp">
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/logo1"
android:layout_width="fill_parent"
android:layout_height="100sp"
android:orientation="horizontal"
android:layout_weight="1"
android:padding="2dp"
android:background="@color/colorPrimary">
<LinearLayout
android:id="@+id/mobileRelView"
android:orientation="vertical"
android:weightSum="2"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="1dp"
android:onClick="goToMobileForm"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:padding="7dp"
android:id="@+id/mobile_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="1dp"
android:clickable="false"
android:layout_weight="1.3"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/mobile_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Mobile" />
<View
android:layout_width="70dp"
android:layout_height="2dp"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:background="#424242" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#424242" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:onClick="goToDesktopForm"
android:weightSum="2"
android:clickable="true"
android:paddingLeft="2dp"
android:paddingRight="1dp"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:padding="7dp"
android:id="@+id/desktop_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:clickable="false"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/desktop_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Desktop" />
<View
android:layout_width="70dp"
android:layout_height="2dp"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:background="#424242" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#424242" />
<LinearLayout
android:layout_width="match_parent"
android:paddingLeft="1dp"
android:orientation="vertical"
android:onClick="goToLaptopForm"
android:weightSum="2"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:padding="7dp"
android:id="@+id/laptop_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:clickable="false"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/laptop_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Laptop" />
<View
android:layout_width="70dp"
android:layout_height="2dp"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:background="#424242" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/logobutton1"
android:layout_width="fill_parent"
android:layout_height="100sp"
android:orientation="horizontal"
android:layout_weight="1"
android:padding="2dp"
android:background="@color/colorPrimary">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="2dp"
android:paddingLeft="1dp"
android:onClick="gotToOthersForm"
android:weightSum="2"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/homeappliances_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:padding="7dp"
android:clickable="false"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/homeappliances_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Home Appliance" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#424242" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="1dp"
android:weightSum="2"
android:onClick="goToDesktopForm"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/cleaning_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:clickable="false"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"
android:padding="7dp" />
<TextView
android:id="@+id/cleaning_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Automobile" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#424242" />
<LinearLayout
android:orientation="vertical"
android:weightSum="2"
android:onClick="gotToOthersForm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="1dp"
android:layout_weight="0.25"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/othrs_Image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3"
android:scaleType="fitCenter"
android:clickable="false"
android:src="@mipmap/ic_launcher"
android:padding="7dp" />
<TextView
android:id="@+id/others_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center"
android:clickable="false"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="@dimen/mainbuttontext"
android:text="Others"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="150sp">
<!--<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#6A1B9A"
android:textStyle="bold"
android:background="#ffb300"
android:textSize="15sp"
android:text="Why eFix ?" />
-->
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="2dp"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
首次导入时重复输入
pd.read_csv
我只能写一次“N01”,大约只在第一行,自动代码插入所有行。
我需要实现这段代码,因为在第二,第三,......时间我需要将'N01'更改为'N02'并在......之后,'N11'
答案 0 :(得分:0)
使用循环:
for n in range(1, 12):
for time in ('5mins', '10mins', '15mins'):
print('{time}/nodes/{n:0>2}'.format(time=time, n=n))
然后您可以轻松地将它们存储在字典中
from itertools import product
dct = {}
for idx, (n, time) in enumerate(product(range(1, 12), ('5mins', '10mins', '15mins')), 1):
dct['node{:0>2}'.format(idx)] = pd.read_csv('{time}/nodes/{n:0>2}'.format(time=time, n=n))
print(dct)
这将是这样的(除了值是你的csv
文件而不是字符串):
{'node01': '5mins/nodes/01',
'node02': '10mins/nodes/01',
'node03': '15mins/nodes/01',
'node04': '5mins/nodes/02',
'node05': '10mins/nodes/02',
....
'node31': '5mins/nodes/11',
'node32': '10mins/nodes/11',
'node33': '15mins/nodes/11'}