回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我想让我的代码更干净。你知道吗</p>
<p>我想做一些类似的事情:</p>
<pre><code>gesture_sensor_data = [nod_gyro, nod_acc, swipe_left_gyro, swipe_right_acc, etc.]
</code></pre>
<p>我现在有这个:</p>
<pre><code>nod_gyro, nod_acc = fill_gyro_and_acc_data(nod_intervals, merge)
swipe_right_gyro, swipe_right_acc = fill_gyro_and_acc_data(swipe_right_intervals, merge)
swipe_left_gyro, swipe_left_acc = fill_gyro_and_acc_data(swipe_left_intervals, merge)
whats_up_gyro, whats_up_acc = fill_gyro_and_acc_data(whats_up_intervals, merge)
</code></pre>
<p>我想通过<code>gesture_sensor_data</code>运行一个循环。你知道吗</p>
<p>有办法吗?某种结构什么的?你知道吗</p>
<p>编辑:我将在这个函数中显示我的完整代码作为上下文。你知道吗</p>
<pre><code>def generate_gesture_files(i):
nod_intervals, swipe_left_intervals, swipe_right_intervals, whats_up_intervals = generate_gesture_intervals(i)
merge = pandas.read_csv(final_user_study_path + "/P" + str(i) + "/DataCollection/data/merge.csv")
nod_gyro, nod_acc = fill_gyro_and_acc_data(nod_intervals, merge)
swipe_right_gyro, swipe_right_acc = fill_gyro_and_acc_data(swipe_right_intervals, merge)
swipe_left_gyro, swipe_left_acc = fill_gyro_and_acc_data(swipe_left_intervals, merge)
whats_up_gyro, whats_up_acc = fill_gyro_and_acc_data(whats_up_intervals, merge)
return nod_gyro, nod_acc, swipe_right_gyro, swipe_right_acc, swipe_left_gyro, swipe_right_acc, whats_up_gyro, whats_up_acc
</code></pre>