我有一个琐事程序,我需要修改以添加高分存储功能。我已将代码修改为要求但我收到错误:
global $curl_init;
$proxy = '201.172.53.123:10000';
//$proxyauth = 'user:password';
curl_setopt($curl_init, CURLOPT_URL, $url);
curl_setopt($curl_init, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($curl_init, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_init, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_init, CURLOPT_HEADER, 1);
curl_setopt($curl_init, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
curl_setopt($curl_init, CURLOPT_SSL_VERIFYPEER, false);
echo $curl_scraped_page = curl_exec($curl_init);
我的问题是:在函数high_scores中,如何获得我在line 99, in high_scores
entry = (score,name)
NameError: name 'score' is not defined*
函数中定义的变量score
?我已经在主函数中返回了变量分数,但我不知道如何在main()
的第二个函数中使用它。
以下是代码:
high_scores()
答案 0 :(得分:2)
将其作为参数传递:
def high_scores(score):
...
...
def main():
...
high_scores(score)