给定一个百分比0-100,一个人怎么可能在x%的时间内返回值“ y”。
例如,如果我要在30%的时间内返回字符串“是”
myfunc(30)
def myfunc(percentage):
# Do something here that "yes" will return 30% of the time
return "yes"
答案 0 :(得分:2)
使用function calcTime(city, offset) {
// create Date object for current location
var d = new Date();
// convert to msec
// add local time zone offset
// get UTC time in msec
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
var nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time in " + city + " is " + nd.toLocaleString();
}
random