本文整理匯總了Python中faker.providers.internet方法的典型用法代碼示例。如果您正苦於以下問題:Python providers.internet方法的具體用法?Python providers.internet怎麽用?Python providers.internet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類faker.providers
的用法示例。
在下文中一共展示了providers.internet方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_file
# 需要導入模塊: from faker import providers [as 別名]
# 或者: from faker.providers import internet [as 別名]
def generate_file(filename, generated_type):
print("Generating " + filename)
with open(filename, 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
generated_set = set()
fake = Faker()
fake.add_provider(internet)
fake.add_provider(date_time)
soFar = 0
total = 2000000
while len(generated_set) != total:
indicator, csv_line = generate_indicator(fake, generated_type)
if indicator in generated_set:
continue
generated_set.add(indicator)
writer.writerow(csv_line)
soFar += 1
if (soFar % 10000 == 0):
print(f"Finished {soFar} out of {total}")
print("Finished" + filename)