Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何在另一个函数中调用此函数?_String_Function_Numbers_Call_Phone Number - Fatal编程技术网

String 如何在另一个函数中调用此函数?

String 如何在另一个函数中调用此函数?,string,function,numbers,call,phone-number,String,Function,Numbers,Call,Phone Number,目前我正在尝试创建无限的随机电话号码。但是,调用函数的某些功能不起作用。请帮助我,这是我的代码: def phone_number(self): request = requests.get('https://www.bestrandoms.com/random-at-phone-number') soup = BeautifulSoup(request.content, 'html.parser') self.phone_numbers = soup.select_o

目前我正在尝试创建无限的随机电话号码。但是,调用函数的某些功能不起作用。请帮助我,这是我的代码:

def phone_number(self):
    request = requests.get('https://www.bestrandoms.com/random-at-phone-number')
    soup = BeautifulSoup(request.content, 'html.parser')

    self.phone_numbers = soup.select_one('#main > div > div.col-xs-12.col-sm-9.main > ul > textarea').text
    self.phone_numbers = self.phone_numbers.splitlines()
    for phone in range(len(self.phone_numbers)):
        self.phone_numbers[phone] = '+43' + self.phone_numbers[phone][1:].replace(' ', '')

    self.phone_numbers.extend(self.phone_numbers)
    return self.phone_numbers

@property
def next_phone_number(self):
    self.phone_index += 1
    if self.phone_index >= len(self.phone_numbers):
        self.phone_number()

    return self.phone_numbers[self.phone_index]