SpringBoot 在線協同辦公小程序開發 全棧式項目實戰

download:SpringBoot 在線協同辦公小程序開發 全棧式項目實戰

未來,在線協同辦公將成爲一種常態化的工作方式。本課程將採用最流行的前後端分離架構設計,應用 SpringBoot+uniapp 技術棧開發一款在線協同辦公的小程序。讓你掌握未來趨勢型業務 + 前後端綜合技術棧,帶你實現全技術棧的綜合提升。

技術要求
1.HTML / CSS 基礎 2.JS 交互知識 3.基本的 Vue 知識 4.JavaWeb 相關知識
環境參數
SpringBoot 2.3、uni-app2.9 開發工具:IDEA、HBuilderX


1。四位數字字母驗證碼的生成實例

複製代碼
1 import random
2 if name =="main": #四位數字字母驗證碼的生成
3 checkcode="" #保存驗證碼的變量
4 for i in range(4):
5 index=random.randrange(0,4) #生成一個0~3中的數
6 if index!=i and index +1 !=i:
7 checkcode +=chr(random.randint(97,122)) # 生成a~z中的一個小寫字母
8 elif index +1==i:
9 checkcode +=chr(random.randint(65,90) ) # 生成A~Z中的一個大寫字母
10 else:
11 checkcode +=str(random.randint(1,9)) # 數字1-9
12 print(checkcode)
複製代碼
輸出爲:m47A、8wQ9、vugS














2。格式化時間函數

1 def formatTime(longtime):
2 '''格式化時間的函數'''
3 import time
4 return time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(longtime))


3。記錄顯示登錄日誌實例

複製代碼
import time

def show_info():
print('''輸入提示數字,執行相應操作
0:退出
1:查看登錄日誌
''')



def write_loginfo(username):
"""
將用戶名和登錄時間寫入日誌
:param username: 用戶名
"""
with open('log.txt','a') as f:
string = "用戶名:{} 登錄時間:{}\n".format(username ,time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
f.write(string)






def read_loginfo():
"""
讀取日誌
"""
with open('log.txt','r') as f:
while True:
line = f.readline()
if line == '':
break # 跳出循環
print(line) # 輸出一行內容








if name == "main":

輸入用戶名

username = input('請輸入用戶名:')
# 檢測用戶名
while len(username) < 2 :
    print('用戶名長度應不少於2位')
    username = input('請輸入用戶名:')
# 輸入密碼
password = input('請輸入密碼:')
# 檢測密碼
while len(passw ord) < 6 :
    print('密碼長度應不少於6位')
    password = input('請輸入密碼:')

print('登錄成功')
write_loginfo(username)  # 寫入日誌
show_info()              # 提示信息
num = int(input('輸入操作數字:')) # 輸入數字
while True:
    if num == 0:
        print('退出成功')
        break
    elif num == 1:
        print('查看登錄日誌')
        read_loginfo()
        show_info()
        num = int(input('輸入操作數字:'))
    else:
        print('您輸入的數字有誤')
        show_info()
        num = int(input('輸入操作數字:'))

3。模擬淘寶客服自動回覆
複製代碼
1 # 任務2:模擬淘寶客服自動回覆
2
3 def find_answer(question):
4 with open('reply.txt','r') as f :
5 while True:
6 line=f.readline()
7 if not line: #也可以爲if line==''
8 break
9 keyword=line.split('|')[0]
10 reply=line.split('|')[1]
11 if keyword in question:
12 return reply
13 return '對不起,沒有你想要找的問題'
14
15 if name =='main':
16 question=input('請輸入想要提問的內容:')
17 while True:
18 if question=='bye':
19 break
20 reply=find_answer(question)
21 if not reply:
22 question=input("小蜜不懂您在說什麼,您可以問一些與訂單、賬戶和支付相關的內容(退出請輸入bye):")
23 else:
24 print(reply)
25 question=input("您可以問一些與訂單、賬戶和支付相關的內容(退出請輸入bye):")
26 print('謝謝,再見!')
27
複製代碼




























複製代碼

4。求最大公約數和最小公倍數 (輾轉相除法)
最大公約數:指兩個或多個整數共有約數中最大的一個

最小公倍數:兩個或多個整數公有的倍數叫做它們的公倍數,其中除0以外最小的一個公倍數就叫做這幾個整數的最小公倍數

二者關係:兩個數之積=最小公倍數*最大公約數

複製代碼
1 a=int(input('輸入數字1:'))
2 b=int(input('輸入數字2:'))
3 s=a*b
4 while a%b!=0:
5 a,b=b,(a%b)
6 print(a)
7 print(b)
8 else:
9 print(b,'is the maximum common divisor最大公約數')
10 print(s//b,'is the least common multiple,最小公倍數')









發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章