#生成数字
def chinese_number(num):
"""Converts a number to its Chinese numeric representation."""
units = ["", "十", "百", "千"]
digits = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"]
if num < 10:
return digits[num]
elif num < 20:
return "十" + (digits[num % 10] if num % 10 > 0 else "")
else:
result = ""
str_num = str(num)
length = len(str_num)
for i, digit in enumerate(str_num):
n = int(digit)
if n != 0:
result += digits[n] + units[length - 1 - i]
elif not result.endswith("零"):
result += "零"
return result.rstrip("零")
# Generating the chapter titles
chapter_titles = [f"第{chinese_number(i)}章" for i in range(1, 10000)]
w=open('www.txt','w',encoding='utf-8')
for da in chapter_titles:
w.write(da+"\n")
w.close()
print('okk')
05-18