首页 > 代码库 > python 获取时间 存入文件

python 获取时间 存入文件

1读文件:

file_path_name = ‘/home/robot/bzrobot_ws/src/bzrobot/bzrobot_comm/led_show_data/‘+file_name+‘.txt‘
open_file = open(led_file_path_name, ‘r‘)
data_read_file = open_file.read(4096)

 

2.写文件:

sys_time = rospy.get_time()

desk_path_name = ‘/home/wang/Desktop‘ (ubuntu的桌面路径)

write_file = open(led_file_path_name, ‘w‘)

write_file.write(str(sys_time))

python 获取时间 存入文件