import time
# Get the current time and format as a string
timestring = time.strftime('%H:%M%p', time.gmtime()).lower()
# Create a format string for the STOR command
stor_format = 'STOR {}.png'
# Format the format string with the timestring
session.storbinary(stor_format.format(timestring), open(bacteria,'rb'))
你可以这样做:
^{} 获取UTC时间-如果您喜欢使用本地时间,请使用^{} 。你知道吗
^{} 使用提供的格式将时间格式化为字符串。格式字符串
'%H:%S%p'
将时间格式化为两位数的小时和分钟,用冒号分隔,后跟'AM'或'PM'。对.lower()
的结果调用time.strftime()
会将“AM”或“PM”转换为小写形式:“AM”或“PM”。你知道吗通过用
'{}'
占位符替换STOR命令中的单词“bacteria”,可以创建所需的STOR命令。你知道吗相关问题 更多 >
编程相关推荐