如果孩子每7秒钟出生一次,我正在使用python来计算出5年内会有多少孩子出生.问题出在我的最后一行.当我在其两侧打印文本时,如何使变量起作用?
这是我的代码:
currentPop = 312032486
oneYear = 365
hours = 24
minutes = 60
seconds = 60
# seconds in a single day
secondsInDay = hours * minutes * seconds
# seconds in a year
secondsInYear = secondsInDay * oneYear
fiveYears = secondsInYear * 5
#Seconds in 5 years
print fiveYears
# fiveYears in seconds, divided by 7 seconds
births = fiveYears // 7
print "If there was a birth every 7 seconds, there would be: " births "births"
Run Code Online (Sandbox Code Playgroud) 单击按钮时如何在Tkinter中弹出一个弹出窗口?单击"关于"按钮后,我想要弹出一个免责声明+关于文本.
我试图建立一个def方法,但它一定是非常错误的,因为它不能按我的意愿工作.任何帮助将非常感谢.
谢谢
import sys
from Tkinter import *
def clickAbout():
name = ("Thanks for the click")
return
app = Tk()
app.title("SPIES")
app.geometry("500x300+200+200")
labelText = StringVar()
labelText.set ("Please browse to the directory you wish to scan")
labelText2 = StringVar()
labelText2.set ("About \n \n \
SPIES will search your chosen directory for photographs containing \n \
GPS information. SPIES will then plot the co-ordinates on Google \n \
maps so you can see where each photograph was taken.")
labelText3 = StringVar() …
Run Code Online (Sandbox Code Playgroud) 当我运行下面的代码时,我收到以下错误:eval()arg 1必须是字符串或代码对象
谁知道为什么?这是我从一本书中学习的代码,所以我认为它是正确的.
# Prompt the user to enter three numbers
number1 = eval(input("Enter the first number: "))
number2 = eval(input("Enter the second number: "))
number3 = eval(input("Enter the third number: "))
# Compute average
average = (number1 + number2 + number3) / 3
print("The average of", number1, number2, number3, "is", average)
Run Code Online (Sandbox Code Playgroud)