本文整理汇总了Python中exrex.getone方法的典型用法代码示例。如果您正苦于以下问题:Python exrex.getone方法的具体用法?Python exrex.getone怎么用?Python exrex.getone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exrex
的用法示例。
在下文中一共展示了exrex.getone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: regex_to_str
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def regex_to_str(self, all_combo: bool = False):
"""Convert a regex to a matching string
Args:
all_combo (bool, optional): Generate all combos that match regex. Defaults to False.
Returns:
Chepy: The Chepy object.
"""
if all_combo:
self.state = list(exrex.generate(self._convert_to_str()))
else:
self.state = exrex.getone(self._convert_to_str())
return self
示例2: get_random
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def get_random(self):
"""Returns a random string matching the regex"""
return exrex.getone(self.options['regex'])
示例3: get_random_list
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def get_random_list(self, num_values):
"""Returns a list of num_values random strings matching regex; note that matches may be repeated"""
return [exrex.getone(self.options['regex']) for _ in range(num_values)]
示例4: generate_random_format_string
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def generate_random_format_string(format_string):
try:
return getone(format_string)
except Exception as e:
print(e)
return ""
示例5: _generate_fake_users
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def _generate_fake_users(self):
FAKER = Faker('it_IT')
_users = {}
for idx, _ in enumerate(range(10)):
_is_even = (idx % 2 == 0)
name = FAKER.first_name_male() if _is_even \
else FAKER.first_name_female()
lastname = FAKER.last_name_male() if _is_even \
else FAKER.last_name_female()
fiscal_number = exrex.getone(
r'[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]'
)
spid_code = 'TENV{}'.format(
FAKER.lexify('??????????', string.ascii_letters + string.digits)
)
_users[FAKER.user_name() if idx > 0 else 'test'] = {
'attrs': {
'spidCode': spid_code,
'name': name,
'familyName': lastname,
'gender': 'M' if _is_even else 'F',
'dateOfBirth': FAKER.date(),
'companyName': FAKER.company(),
'registeredOffice': FAKER.address(),
'fiscalNumber': 'TINIT-{}'.format(fiscal_number),
'email': FAKER.email()
},
'pwd': 'test',
'sp': None
}
return _users
示例6: createUsername
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import getone [as 别名]
def createUsername():
return exrex.getone('[a-zA-Z]{1}[a-zA-Z0-9._\-]{1,}')