我有四个变量:-
measure = 'domain.bandwidth' (string type)
time = datetime.datetime.now() (datetime type)
players_count = 50 (int type)
bandwidth = 3672782 (int type)我使用下面的代码获得所需的输出:-
import datetime
measure = 'domain.bandwidth'
time = datetime.datetime.now()
players_count = 50
bandwidth = 3672782
print('%s,time=%s,players_count=%s,bandwidth=%s'
% (measure, time.strftime('%Y-%M-%d %H:%I:%S.%f'), players_count, bandwidth))输出:- domain.bandwidth,time=2020-09-23T16:51:35Z,last_minute_total_players=227,last_minute_outgoing_bandwidth_bytes=1775874
我要输出如下:-
domain.bandwidth time=2020-09-23T16:51:35Z,last_minute_total_players=227,last_minute_outgoing_bandwidth_bytes=1775874它是domain.bandwidth和time之间的空格,而不是逗号。
发布于 2020-09-23 17:00:09
你想要这个吗?
import datetime
measure = 'domain.bandwidth'
time = datetime.datetime.now()
players_count = 50
bandwidth = 3672782
print('%s time=%s,players_count=%s,bandwidth=%s'
% (measure, time.strftime('%Y-%M-%d %H:%I:%S.%f'), players_count, bandwidth))输出:
domain.bandwidth time=2020-59-23 18:06:12.007382,players_count=50,bandwidth=3672782发布于 2020-09-23 16:59:43
尝尝这个
new_time = time.strftime('%Y-%M-%d %H:%I:%S.%f')
print(f"{measure} time={new_time}, last_minute_total_players={players_count}, last_minute_outgoing_bandwidth_bytes={bandwidth}")https://stackoverflow.com/questions/64032789
复制相似问题