标签:def inpu elf 函数 strong blog tle filename save
from docx import Documentclass Word:
def init(self):
self.doc = Document()
def write_word(self):
‘‘‘主函数‘‘‘
titles = input(‘请输入标题:‘)
self.add_titles(titles) #可以在被的函数中通过self调用其它的函数方法,self即为类本身
sub_titles = input(‘请输入副标题:‘)
self.add_subtitles(sub_titles)
para = input(‘请输入正文:‘)
self.add_paragraphs(para)
filename = input(‘请输入文件名:‘)
self.save_docss(filename)
def add_titles(self, text):
‘‘‘添加标题方法‘‘‘
self.doc.add_heading(text)
def add_subtitles(self, subtitle):
self.doc.add_paragraph(subtitle, ‘Subtitle‘)
def add_paragraphs(self,para):
self.doc.add_paragraph(para)
def save_docss(self, filename):
name =filename + ‘.‘ + ‘docx‘
self.doc.save(name)
def main():
aa = Word()
aa.write_word()
if name =="main":
main()
请输入标题:aa
请输入副标题:bb
请输入正文:cc
请输入文件名:dd
os.
Object join
not found.
import math
class Shttps://blog.csdn.net/shkfpwzolution(object):
def is_square(self,n):
s=int(math.sqrt(n))
return s*s==n
def numSquares(self, n):
if Solution.is_square(self,n)==True:
return 1
while n%4==0:
n=n/4
if n%8==7:
return 4
i=1
while i*i<n:
if Solution.is_square(self,n-i*i)==True:
return 2
i+=1
return 3
import math
class Solution(object):
def is_square(self,n):
s=int(math.sqrt(n))
return s*s==n
def numSquares(self, n):
if self.is_square(n)== True:
return 1
while n%4==0:
n=n/4
if n%8==7:
return 4
i=1
while i*i<n:
if self.is_square(n-i*i)==True:
return 2
i+=1
return 3
标签:def inpu elf 函数 strong blog tle filename save
原文地址:https://blog.51cto.com/14308899/2551442