简体   繁体   English

存储来自用户输入的多个输入

[英]Storing multiple inputs from user entry

I want know how i can create a notifier that can store more than 1 time and note given by user entry from a little gui. 我想知道我如何创建一个可以存储1次以上的通知程序,并通过一个小gui记录用户输入的注释。 this code is the very basic i am using: 这段代码是我正在使用的最基本的代码:

from datetime import datetime
from threading import Timer
from tkinter import messagebox
from tkinter import *
from inputer import *


x = datetime.today()
y = x.replace(day=q, hour=w, minute=e, second=0, microsecond=0)

delta_t = y - x

secs = delta_t.seconds+1

def Note():
    # in this function i put the commands to open 
    # a small window with the reminder/note
    print("hello world")
    #...

t = Timer(secs, Note)
t.start()

"inputer" is the file taking the user input. “输入程序”是接受用户输入的文件。 if for example i want to get 2 reminders at the same day. 例如,如果我想在同一天收到2条提醒。 how do i code that? 我该如何编码? because now the variables for day and time are fixed and can not store more info to use at a certain time. 因为现在日期和时间的变量是固定的,并且无法存储在特定时间使用的更多信息。

i am very new to coding sorry if this question seems stupid xd (using python btw) 如果这个问题看起来很愚蠢,我对编码感到很陌生(使用python btw)

After clarifying I think this would be best, you have multiple timestamps you could store in a list or dictionary 弄清楚我认为这是最好的之后,您可以将多个时间戳存储在列表或字典中

List 名单

timestamps = []
timestamp_1 = '1h1m1s' # these variables can be assigned with input() as well
timestamp_2 = '2h2m2s'

timestamps.append(timestamp_1)
timestamps.append(timestamp_2)

print(timestamps[0])
print(timestamps[1])
 chrx@chrx:~/python/stackoverflow/9.23$ python3.7 loop.py 1h1m1s 2h2m2s 

Dictionary 字典

timestamps = {}
timestamp_3 = '3h3m3s'
timestamp_4 = '4h4m4s'

timestamps['ts_3'] = timestamp_3
timestamps['ts_4'] = timestamp_4

print(timestamps['ts_3'])
print(timestamps['ts_4'])
 3h3m3s 4h4m4s 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM