| 查看: 1447 | 回复: 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) |
» 猜你喜欢
请问哪里可以有青B申请的本子可以借鉴一下。
已经有4人回复
真诚求助:手里的省社科项目结项要求主持人一篇中文核心,有什么渠道能发核心吗
已经有6人回复
孩子确诊有中度注意力缺陷
已经有14人回复
三甲基碘化亚砜的氧化反应
已经有4人回复
请问下大家为什么这个铃木偶联几乎不反应呢
已经有5人回复
请问有评职称,把科研教学业绩算分排序的高校吗
已经有5人回复
2025冷门绝学什么时候出结果
已经有3人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
AI论文写作工具:是科研加速器还是学术作弊器?
已经有3人回复
【答案】应助回帖
★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
感谢参与,应助指数 +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 (幼儿园)
- 金币: 9416
- 散金: 600
- 红花: 4
- 帖子: 2049
- 在线: 196小时
- 虫号: 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













回复此楼