主頁 > 後端開發 > 建議收藏!獻給Python初學者的22個入門小專案,練手必備!

建議收藏!獻給Python初學者的22個入門小專案,練手必備!

2021-10-21 06:11:47 後端開發

Python的各種第三方庫,能夠完成很多好玩的操作,給大家展現幾個Python實作的小玩意,看看大家都做過沒~
在這里插入圖片描述
大家也可根據專案的目的及提示,自己構建解決方法,一起在評論區交流~

1、短網址生成器

撰寫一個Python腳本,使用API縮短給定的URL,

from __future__ import with_statement
import contextlib
try:
    from urllib.parse import urlencode
except ImportError:
    from urllib import urlencode
try:
    from urllib.request import urlopen
except ImportError:
    from urllib2 import urlopen
import sys

def make_tiny(url):
    request_url = ('http://tinyurl.com/api-create.php?' + 
    urlencode({'url':url}))
    with contextlib.closing(urlopen(request_url)) as response:
        return response.read().decode('utf-8')

def main():
    for tinyurl in map(make_tiny, sys.argv[1:]):
        print(tinyurl)

if __name__ == '__main__':
    main()
-----------------------------OUTPUT------------------------
python url_shortener.py https://www.wikipedia.org/
https://tinyurl.com/buf3qt3

 

兄弟們學習python,有時候不知道怎么學,從哪里開始學,掌握了基本的一些語法或者做了兩個案例后,不知道下一步怎么走,不知道如何去學習更加高深的知識,
那么對于這些大兄弟們,我準備了大量的免費視頻教程,PDF電子書籍,以及視頻源的源代碼!
還會有大佬解答!
都在這個群里了 點這里立即進裙
歡迎加入,一起討論 一起學習!

2、故事生成器

每次用戶運行程式時,都會生成一個隨機的故事,

random模塊可以用來選擇故事的隨機部分,內容來自每個串列里,

import random
when=['A few years ago''Yesterday''Last night', 'A long time ago' , 'On 20th Jan']
who=['a rabbit','an elephant', 'a mouse', 'a turtle', 'a cat']
name=[ 'Ali '"Miriam' , "danicL','Hoouk",‘Starwalker'1
residence-[ 'Barcelona' , " India','Germany','Venice', 'England']
went= [ 'cinema',"university' , ' seminar', 'school','laundry ']
happened =['made a lot of friends' , 'Eats a burger','found a secret key', ' solved a mistery'" wrote a book"]
print( random.choice(when) + ',' +random.choice(who) + ' that lived in ' +
random.choice(residence) +', went to the ' + random.choice(went) + ' and ' +
random.choice(happened))
-----------------------------------------OUTPUT-----------------------------------------
A long time ago, a cat that lived in England, went to the seminar and solved a mistery

 

3、郵件地址切片器

撰寫一個Python腳本,可以從郵件地址中獲取用戶名和域名,

使用@作為分隔符,將地址分為分為兩個字串,

#Get the user 's email address
email = input("what is your email address ?: ").strip()
# Slice out the user name
email = input("what is your email address ?: ").strip()
# Slice out the user name
domain_name = email[email.index("a")+1:]
#Format message
res = f"Your username is '{user_name}’ and your domain name is '{domain_name}"
# Display the result message
print(res)
--------------------------------OUTPUT------------------------------------------
what is your email address?: karl31agmail.com
Your username is "karl31" and your domain name is 'gmail.com

 

4、句子生成器

通過用戶提供的輸入,來生成隨機且唯一的句子,

以用戶輸入的名詞、代詞、形容詞等作為輸入,然后將所有資料添加到句子中,并將其組合回傳,

color = input("Enter a color:“)
pluralNoun= input("Enter a plural noun: ")
celebrity input("Enter a celebrity: ")
print("Roses are" ,color)
print(pluralNoun+ " are blue")
print(I love" , celebrity)
-----------------------------------------------
Red
Teeth
RDJ
Roses are red. teeth are blue. I Love RDJ

 

5、自動發送郵件

撰寫一個Python腳本,可以使用這個腳本發送電子郵件,

email庫可用于發送電子郵件,

import smtplib 
from email.message import EmailMessage
email = EmailMessage() ## Creating a object for EmailMessage
email['from'] = 'xyz name'   ## Person who is sending
email['to'] = 'xyz id'       ## Whom we are sending
email['subject'] = 'xyz subject'  ## Subject of email
email.set_content("Xyz content of email") ## content of email
with smtlib.SMTP(host='smtp.gmail.com',port=587)as smtp:     
## sending request to server 
    smtp.ehlo()          ## server object
smtp.starttls()      ## used to send data between server and client
smtp.login("email_id","Password") ## login id and password of gmail
smtp.send_message(email)   ## Sending email
print("email send")    ## Printing success message

 

6、猜數字游戲

在這個游戲中,任務是創建一個腳本,能夠在一個范圍內生成一個亂數,如果用戶在三次機會中猜對了數字,那么用戶贏得游戲,否則用戶輸,

生成一個亂數,然后使用回圈給用戶三次猜測機會,根據用戶的猜測列印最終的結果,

import random
nunber = random.randint(1,10)
for i in range(e,3):
    user =int(input("guess the number"))
    if user -number:
       print("Hurray H")
       print(f"you guessed the number right it's {number}")
       break
    elif user>number:
       print("Your guess is too high")
    elif userenuimber:
       print(Your guess is too low.")
else:
    print(f"Nice Try!,but the number is {number}")

 

7、石頭剪刀布游戲

創建一個命令列游戲,游戲者可以在石頭、剪刀和布之間進行選擇,與計算機PK,如果游戲者贏了,得分就會添加,直到結束游戲時,最終的分數會展示給游戲者,

接收游戲者的選擇,并且與計算機的選擇進行比較,計算機的選擇是從選擇串列中隨機選取的,如果游戲者獲勝,則增加1分,

import random
choices = ["Rock", "Paper", "Scissors"]
computer = random.choice(choices)
player = False
cpu_score = 0
player_score = 0
while True:
    player = input("Rock, Paper or  Scissors?").capitalize()
    # 判斷游戲者和電腦的選擇
    if player == computer:
        print("Tie!")
    elif player == "Rock":
        if computer == "Paper":
            print("You lose!", computer, "covers", player)
            cpu_score+=1
        else:
            print("You win!", player, "smashes", computer)
            player_score+=1
    elif player == "Paper":
        if computer == "Scissors":
            print("You lose!", computer, "cut", player)
            cpu_score+=1
        else:
            print("You win!", player, "covers", computer)
            player_score+=1
    elif player == "Scissors":
        if computer == "Rock":
            print("You lose...", computer, "smashes", player)
            cpu_score+=1
        else:
            print("You win!", player, "cut", computer)
            player_score+=1
    elif player=='E':
        print("Final Scores:")
        print(f"CPU:{cpu_score}")
        print(f"Plaer:{player_score}")
        break
    else:
        print("That's not a valid play. Check your spelling!")
    computer = random.choice(choices)

 

8、維基百科文章摘要

使用一種簡單的方法從用戶提供的文章鏈接中生成摘要,

你可以使用爬蟲獲取文章資料,通過提取生成摘要,

from bs4 import BeautifulSoup
import re
import requests
import heapq
from nltk.tokenize import sent_tokenize,word_tokenize
from nltk.corpus import stopwords

url = str(input("Paste the url"\n"))num = int(input("Enter the Number of Sentence you want in the summary"))
num = int(num)
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}#url = str(input("Paste the url......."))
res = requests.get(url,headers=headers)summary = ""
soup = BeautifulSoup(res.text,'html.parser') content = soup.findAll("p")
for text in content:
    summary +=text.text 
def clean(text):    text = re.sub(r"\[[0-9]*\]"," ",text)
    text = text.lower()    text = re.sub(r'\s+'," ",text)    text = re.sub(r","," ",text)
    return text
summary = clean(summary)
print("Getting the data......\n")


##Tokenixing
sent_tokens = sent_tokenize(summary)
summary = re.sub(r"[^a-zA-z]"," ",summary)
word_tokens = word_tokenize(summary)
## Removing Stop words

word_frequency = {}stopwords =  set(stopwords.words("english"))

for word in word_tokens:
    if word not in stopwords:
        if word not in word_frequency.keys():
            word_frequency[word]=1
        else:
            word_frequency[word] +=1
maximum_frequency = max(word_frequency.values())
print(maximum_frequency)          
for word in word_frequency.keys():
    word_frequency[word] = (word_frequency[word]/maximum_frequency)
print(word_frequency)
sentences_score = {}
for sentence in sent_tokens:
    for word in word_tokenize(sentence):
        if word in word_frequency.keys():            if (len(sentence.split(" "))) <30:
                if sentence not in sentences_score.keys():
                    sentences_score[sentence] = word_frequency[word]
                else:
                    sentences_score[sentence] += word_frequency[word]

print(max(sentences_score.values()))
def get_key(val): 
    for key, value in sentences_score.items(): 
        if val == value: 
            return key 
key = get_key(max(sentences_score.values()))print(key+"\n")
print(sentences_score)
summary = heapq.nlargest(num,sentences_score,key=sentences_score.get)print(" ".join(summary))summary = " ".join(summary)

 

9、隨機密碼生成器

創建一個程式,可指定密碼長度,生成一串隨機密碼,

創建一個數字+大寫字母+小寫字母+特殊字符的字串,根據設定的密碼長度隨機生成一串密碼,

import random
passlen = int(input("enter the length of password"))
s="abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLNNOPQRSTUVWXYz!簡#$x^6a()?p=.join(random.sample(s.passlen )
print(p)
-----------------------------------------------------------
enter the length of password6
za1gBe

 

10、鬧鐘

撰寫一個創建鬧鐘的Python腳本,

你可以使用date-time模塊創建鬧鐘,以及playsound庫播放聲音,

from datetime import datetime   
from playsound import playsound
alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n")
alarm_hour=alarm_time[0:2]
alarm_minute=alarm_time[3:5]
alarm_seconds=alarm_time[6:8]
alarm_period = alarm_time[9:11].upper()
print("Setting up alarm..")
while True:
    now = datetime.now()
    current_hour = now.strftime("%I")
    current_minute = now.strftime("%M")
    current_seconds = now.strftime("%S")
    current_period = now.strftime("%p")
    if(alarm_period==current_period):
        if(alarm_hour==current_hour):
            if(alarm_minute==current_minute):
                if(alarm_seconds==current_seconds):
                    print("Wake Up!")
                    playsound('audio.mp3') ## download the alarm sound from link
                    break

 

11、文字冒險游戲

撰寫一個有趣的Python腳本,通過為路徑選擇不同的選項讓用戶進行有趣的冒險,

name = str( input("Enter Your Mame\n"))
print(f"{name} you are stuck in a forest.Your task is to get out from the forest withoutdieing")
print("You are walking threw forest and suddenly a wolf comes in your way.Now Youoptions.")
print("1.Run 2. climb The Nearest Tree ")
user = int(input("choose one option 1 or 2"))
if user = 1:
    print("You Died!!")
elif user = 2:
    print("You Survived!!")
else:
    print("Incorrect Input")
#### Add a loop and increase the story as much as you can

 

12、有聲讀物

撰寫一個Python腳本,用于將Pdf檔案轉換為有聲讀物,

借助pyttsx3庫將文本轉換為語音,

要安裝的模塊:

pyttsx3
PyPDF2

 

import pyttsx3,PyPDF2
DdfReader = pyPDF2.PdfFileReader(open( "file.pdf',"rb'))
speaker = pyttsx3.init()
for page_num in range(pdfReader.numPages):
    text =pdfReader.getPage(page_num).extractText()
    speaker.say(text)
    speaker.runAndwait()
speaker.stopo()

 

13、貨幣換算器

撰寫一個Python腳本,可以將一種貨幣轉換為其他用戶選擇的貨幣,

使用Python中的API,或者通過forex-python模塊來獲取實時的貨幣匯率,

安裝:forex-python

from forex _python.converter import CurrencyRatesc = CurrencyRates()
amount = int(input("Enter The Amount You Want To Convert\n"))
from_currency = input( "From\n" )-upper()
to_currency = input( "To\n").upper()
print(from_currency,"To",to_currency , amount)
result = c.convert(from_currency, to_currency, amount)
print(result)

 

14、天氣應用

撰寫一個Python腳本,接收城市名稱并使用爬蟲獲取該城市的天氣資訊,

你可以使用Beautifulsoup和requests庫直接從谷歌主頁爬取資料,

安裝:

requests
BeautifulSoup

 

from bs4 import BeautifulSoup
import requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

def weather(city):
    city=city.replace(" ","+")
    res = requests.get(f'https://www.google.com/search?q={city}&oq={city}&aqs=chrome.0.35i39l2j0l4j46j69i60.6128j1j7&sourceid=chrome&ie=UTF-8',headers=headers)
    print("Searching in google......\n")
    soup = BeautifulSoup(res.text,'html.parser')   
    location = soup.select('#wob_loc')[0].getText().strip()  
    time = soup.select('#wob_dts')[0].getText().strip()       
    info = soup.select('#wob_dc')[0].getText().strip() 
    weather = soup.select('#wob_tm')[0].getText().strip()
    print(location)
    print(time)
    print(info)
    print(weather+"°C") 

print("enter the city name")
city=input()
city=city+" weather"
weather(city)

 

15、人臉檢測

撰寫一個Python腳本,可以檢測影像中的人臉,并將所有的人臉保存在一個檔案夾中,

可以使用haar級聯分類器對人臉進行檢測,它回傳的人臉坐標資訊,可以保存在一個檔案中,

安裝:

OpenCV

下載:haarcascade_frontalface_default.xml

import cv2
# Load the cascade
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Read the input image
img = cv2.imread('images/img0.jpg')
# Convert into grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Detect faces
faces = face_cascade.detectMultiScale(gray, 1.3, 4)
# Draw rectangle around the faces
for (x, y, w, h) in faces:
    cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
    crop_face = img[y:y + h, x:x + w]  
    cv2.imwrite(str(w) + str(h) + '_faces.jpg', crop_face)
# Display the output
cv2.imshow('img', img)
cv2.imshow("imgcropped",crop_face)
cv2.waitKey()

16、提醒應用

創建一個提醒應用程式,在特定的時間提醒你做一些事情(桌面通知),
Time模塊可以用來跟蹤提醒時間,toastnotifier庫可以用來顯示桌面通知,

安裝:win10toast

from win10toast import ToastNotifier
import time
toaster = ToastNotifier()
try:
    print("Title of reminder")
    header = input()
    print("Message of reminder")
    text = input()
    print("In how many minutes?")
    time_min = input()
    time_min=float(time_min)
except:
    header = input("Title of reminder\n")
    text = input("Message of remindar\n")
    time_min=float(input("In how many minutes?\n"))
time_min = time_min * 60
print("Setting up reminder..")
time.sleep(2)
print("all set!")
time.sleep(time_min)
toaster.show_toast(f"{header}",
f"{text}",
duration=10,
threaded=True)
while toaster.notification_active(): time.sleep(0.005)    

17、Hangman

創建一個簡單的命令列hangman游戲,

創建一個密碼詞的串列并隨機選擇一個單詞,現在將每個單詞用下劃線“”表示,給用戶提供猜單詞的機會,如果用戶猜對了單詞,則將“”用單詞替換,

import time
import random
name = input("What is your name? ")
print ("Hello, " + name, "Time to play hangman!")
time.sleep(1)
print ("Start guessing...\n")
time.sleep(0.5)
## A List Of Secret Words
words = ['python','programming','treasure','creative','medium','horror']
word = random.choice(words)
guesses = ''
turns = 5
while turns > 0:         
    failed = 0             
    for char in word:      
        if char in guesses:    
            print (char,end="")    
        else:
            print ("_",end=""),     
            failed += 1    
    if failed == 0:        
        print ("\nYou won") 
        break              
    guess = input("\nguess a character:") 
    guesses += guess                    
    if guess not in word:  
        turns -= 1        
        print("\nWrong")    
        print("\nYou have", + turns, 'more guesses') 
        if turns == 0:           
            print ("\nYou Lose") 

18、文章朗讀器

撰寫一個Python腳本,自動從提供的鏈接讀取文章,

import pyttsx3
import requests
from bs4 import BeautifulSoup
url = str(input("Paste article url\n"))

def content(url):
  res = requests.get(url)
  soup = BeautifulSoup(res.text,'html.parser')
  articles = []
  for i in range(len(soup.select('.p'))):
    article = soup.select('.p')[i].getText().strip()
    articles.append(article)
    contents = " ".join(articles)
  return contents
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)

def speak(audio):
  engine.say(audio)
  engine.runAndWait()

contents = content(url)
## print(contents)      ## In case you want to see the content

#engine.save_to_file
#engine.runAndWait() ## In case if you want to save the article as a audio file

19、獲取谷歌搜索結果

創建一個腳本,可以根據查詢條件從谷歌搜索獲取資料,

from bs4 import BeautifulSoup 
import requests

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
def google(query):
    query = query.replace(" ","+")
    try:
        url = f'https://www.google.com/search?q={query}&oq={query}&aqs=chrome..69i57j46j69i59j35i39j0j46j0l2.4948j0j7&sourceid=chrome&ie=UTF-8'
        res = requests.get(url,headers=headers)
        soup = BeautifulSoup(res.text,'html.parser')
    except:
        print("Make sure you have a internet connection")
    try:
        try:
            ans = soup.select('.RqBzHd')[0].getText().strip()

        except:
            try:
                title=soup.select('.AZCkJd')[0].getText().strip()
                try:
                    ans=soup.select('.e24Kjd')[0].getText().strip()
                except:
                    ans=""
                ans=f'{title}\n{ans}'

            except:
                try:
                    ans=soup.select('.hgKElc')[0].getText().strip()
                except:
                    ans=soup.select('.kno-rdesc span')[0].getText().strip()

    except:
        ans = "can't find on google"
    return ans

result = google(str(input("Query\n")))
print(result)

獲取結果如下

在這里插入圖片描述

20、鍵盤記錄器

撰寫一個Python腳本,將用戶按下的所有鍵保存在一個文本檔案中,

pynput是Python中的一個庫,用于控制鍵盤和滑鼠的移動,它也可以用于制作鍵盤記錄器,簡單地讀取用戶按下的鍵,并在一定數量的鍵后將它們保存在一個文本檔案中,

from pynput.keyboard import Key, Controller,Listener
import time
keyboard = Controller()


keys=[]
def on_press(key):
    global keys
    #keys.append(str(key).replace("'",""))
    string = str(key).replace("'","")
    keys.append(string)
    main_string = "".join(keys)
    print(main_string)
    if len(main_string)>15:
      with open('keys.txt', 'a') as f:
          f.write(main_string)   
          keys= []     
def on_release(key):
    if key == Key.esc:
        return False

with listener(on_press=on_press,on_release=on_release) as listener:
    listener.join()

21、縮寫詞

撰寫一個Python腳本,從給定的句子生成一個縮寫詞,

你可以通過拆分和索引來獲取第一個單詞,然后將其組合,

text = str(input("Enter a stringin"))
text = text.splitO
acronym = ""
for i in text:
acronym = acronymstr(i[e3).upperOprint(acronym)
-----------------output--------------------------
Python Programming languagePPL

22、骰子模擬器

創建一個程式來模擬擲骰子

當用戶詢問時,使用random模塊生成一個1到6之間的數字,

import random;
while int(input( ' Press 1 to roll the dice or 0 to exit:\n')): print(random.randint(1,6))
-----------------------------------------------

Press 1 to roll the dice or 0 to exit
1
4

以上就是今天分享的內容,針對上面這些專案,有的可以適當調整,歡迎大家在評論區一起交流!

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/327765.html

標籤:Python

上一篇:詳解python中三種高階函式(map,reduce,filter)

下一篇:必須要會的檔案操作物件File,python檔案讀寫操作利器!

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more