| 查看: 1653 | 回复: 4 | ||
zhaoshf901金虫 (著名写手)
|
[求助]
请问如何整齐地输出数据? 已有1人参与
|
|
请问Python中如何整齐地输出数据? while i < len(state_1): x_displacement = state_1.direction_x.displacement y_displacement = state_1.direction_y.displacement z_displacement = state_1.direction_z.displacement x_force = state_1.direction_x.force y_force = state_1.direction_y.force z_force = state_1.direction_z.force x_initial_speed = state_1.direction_x.initial_speed y_initial_speed = state_1.direction_y.initial_speed z_initial_speed = state_1.direction_z.initial_speed x_timestep = state_1.direction_x.time_step y_timestep = state_1.direction_y.time_step z_timestep = state_1.direction_z.time_step x_TF = state_1.direction_x.TF y_TF = state_1.direction_y.TF z_TF = state_1.direction_z.TF x_mass = state_1.direction_x.mass y_mass = state_1.direction_y.mass z_mass = state_1.direction_z.mass #m_msg(str(x_displacement) + " " + str(y_displacement)+ " " + str(z_displacement)+ " | " + str(x_force) + " " + str(y_force) + " " + str(z_force) + " | " + str(x_initial_speed) + " " + str(y_initial_speed) + " " + str(z_initial_speed) + " | " + str(x_TF) + " " + str(y_TF) + " " + str(z_TF) + " | " + str(x_timestep) + " " + str(y_timestep) + " " + str(z_timestep)+ " | " + str(x_mass) + " " + str(y_mass) + " " + str(z_mass) ) f.write(str(x_displacement) + "," + str(y_displacement)+ "," + str(z_displacement)+ "," + str(x_force) + "," + str(y_force) + "," + str(z_force) + "," + str(x_TF) + "," + str(y_TF) + "," + str(z_TF) + "\n" ) #changed i = i + 1 f.flush() 需要整齐地输出这些数据str(x_displacement) + "," + str(y_displacement)+ "," + str(z_displacement)+ "," + str(x_force) + "," + str(y_force) + "," + str(z_force) + "," + str(x_TF) + "," + str(y_TF) + "," + str(z_TF) |
» 猜你喜欢
欢迎发来filecode的Mz6后的代码验证其规律
已经有108人回复
两姐妹,一个辛辛苦苦30岁工作当大学教师,另一个23岁就工作当开车教练
已经有7人回复
重要消息,中午系统在维护
已经有9人回复
时间戳变了,能看出什么问题?
已经有10人回复
明天放榜?
已经有4人回复
投稿咨询
已经有6人回复
时间戳又变了8-15
已经有26人回复
今天维护系统维护 祝所有人 高中
已经有9人回复
哪位老哥知道今年的国自然具体哪一天放榜?
已经有16人回复
2027广东省杰青
已经有8人回复
【答案】应助回帖
★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
感谢参与,应助指数 +1
zhaoshf901: 金币+60, ★有帮助 2018-09-04 21:25:18
jjdg: 金币+1, 感谢参与 2018-09-05 15:06:15
感谢参与,应助指数 +1
zhaoshf901: 金币+60, ★有帮助 2018-09-04 21:25:18
jjdg: 金币+1, 感谢参与 2018-09-05 15:06:15
|
编写一个小函数,定义成 def Myform(str, *value) 第一个变量用来控制输出类型,第二个变量自动搜集所有数据,之后在自定义函数里利用format函数获得想要的结果 |

2楼2018-09-04 20:34:46
zhaoshf901
金虫 (著名写手)
- 应助: 3 (幼儿园)
- 金币: 9417
- 散金: 600
- 红花: 4
- 帖子: 2049
- 在线: 196.2小时
- 虫号: 7099929
- 注册: 2017-08-24
- 专业: 理论和计算化学
3楼2018-09-04 21:24:21

4楼2018-09-05 19:06:11

5楼2018-09-05 19:08:10










回复此楼