串联Zybooks Lab 2.1.2
写两个语句以读取my_city的值,然后是my_state。不提供 迅速的。用current_time,my_city和my_state分配log_entry。值应分开 通过一个空间。如果my_city是休斯顿,而my_state是德克萨斯州的样本输出: 2014-07-26 02:12:18:德克萨斯州休斯顿 注意:不要为输入值编写提示。
current_time = '2014-07-26 02:12:18:'
my_city = ''
my_state = ''
log_entry =
''' Your solution goes here '''
print(log_entry)
我尝试了几种解决方案,它只是打印出日期和时间。自日期以来 时间给了时间,我认为将城市和州字符串串联,然后在日志下添加它们 输入但是它仍然只打印出日期。我不能进入实际的城市和州 因为有一个后端测试,Zybooks增加了另一个城市和州。这就是我 到目前为止尝试过。
concatenated_string = my_city + ' ' + my_state
log_entry = current_time + concatenated_string
Write two statements to read in values for my_city followed by my_state. Do not provide a
prompt. Assign log_entry with current_time, my_city, and my_state. Values should be separated
by a space. Sample output for given program if my_city is Houston and my_state is Texas:
2014-07-26 02:12:18: Houston Texas
Note: Do not write a prompt for the input values.
current_time = '2014-07-26 02:12:18:'
my_city = ''
my_state = ''
log_entry =
''' Your solution goes here '''
print(log_entry)
I've tried several solutions and it is only printing out the date and time. Since the date and
time is given, I figured to concatenate the city and state strings then add them under log
entry however it still only prints out the date. I can't enter the actual city and state
because there is a back end test where Zybooks add a different city and state. Here is what I
have tried so far.
concatenated_string = my_city + ' ' + my_state
log_entry = current_time + concatenated_string
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上弄清楚了。
Actually figured it out.
current_time ='2020-07-26 02:12:18:'
my_city = input()
my_state = input()
log_entry =(current_time +''' + my_city +' +'' + my_state)
print(log_entry)print(log_entry)
此工作!
current_time = '2020-07-26 02:12:18:'
my_city = input()
my_state = input()
log_entry = (current_time + ' ' + my_city + ' ' + my_state)
print(log_entry)
This work for me!!