我需要根据用户的决定更新我的表。我需要知道如何根据用户输入的内容更改单元格中的文本

2024-06-17 10:35:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做Python的冒险。我需要显示已经完成的问题。下面我有我的部分代码,但我需要在每次提问时更新我的表格

x = texttable.Texttable()
x.add_rows([["Music", "Movies", "Sports"], [10, 10, 10], [50, 50, 50], [100, 100, 100]])
table = x.draw()
print table

 user1 = raw_input("\n\n" + play1 + " choose a question:")
  if user1 in done_questions:
    print "This question is already done. Enter another question."
    continue
  elif user1 == "0":
    print "Thank You for Playing."
    break
  else:
    if user1 == "Music 10" or user1 == "music 10":
      answer1 = raw_input("Which artist had the top 3 songs on the billboard since after 'The Beatles'.\n")
      if answer1 == "Ariana Grande" or answer1 == "ariana grande":
        print "You got it right!"
        done_questions.append(user1)
        point_1 += 10
      else:
        print "Sorry. It's Wrong."

Tags: ortheyouinputrawiftablemusic