介绍
Python是一种功能强大的编程语言,可用于自动执行各种任务。无论您是开发小型项目还是大型企业应用程序,Python 都可以帮助您节省时间并简化您的工作流程。
Python是一种伟大的语言,因为它的语法非常简单。10行Python代码完成的工作,在Javascript或C++这样的语言中,需要20行代码。下面是一个简单的 Web 请求的示例:
import requestsr = requests.get("https://www.python.org")print(r.status_code)print(r.text)
fetch(“https://www.python.org").then(res => {if(res.ok) {return res.text();} else {throw new Error(“HTTP error, status = “ + res.status);}}).then(text => {console.log(text);}).catch(error => {console.log(error);});
网址缩短器
importpyshortenerss = pyshorteners.Shortener(api_key="YOUR_KEY")long_url =input("Enter the URL to shorten: ")short_url = s.bitly.short(long_url)print("The shortened URL is: "+ short_url)
创建伪信息
import pandas as pdfrom faker import Faker# Create objectfake = Faker()# Generate datafake.name()fake.text()fake.address()fake.email()fake.date()fake.country()fake.phone_number()fake.random_number(digits=5)# Dataframe creationfakeDataframe = pd.DataFrame({‘date’:[fake.date() for i in range(5)],‘name’:[fake.name() for i in range(5)],‘email’:[fake.email() for i in range(5)],‘text’:[fake.text() for i in range(5)]})print(fakeDataframe)
优酷视频下载器
from pytube import YouTubelink = input("Enter a youtube video's URL") # i.e. https://youtu.be/dQw4w9WgXcQyt = Youtube(link)yt.streams.first().download()print("downloaded", link)
北约音标加密器
def encrypt_message(message):nato_alphabet = {‘A’: ‘Alfa’, ‘B’: ‘Bravo’, ‘C’: ‘Charlie’, ‘D’: ‘Delta’,‘E’: ‘Echo’, ‘F’: ‘Foxtrot’, ‘G’: ‘Golf’, ‘H’: ‘Hotel’,‘I’: ‘India’, ‘J’: ‘Juliet’, ‘K’: ‘Kilo’, ‘L’: ‘Lima’,‘M’: ‘Mike’, ’N’: ‘November’, ‘O’: ‘Oscar’, ‘P’: ‘Papa’,‘Q’: ‘Quebec’, ‘R’: ‘Romeo’, ‘S’: ‘Sierra’, ‘T’: ‘Tango’,‘U’: ‘Uniform’, ‘V’: ‘Victor’, ‘W’: ‘Whiskey’, ‘X’: ‘Xray’,‘Y’: ‘Yankee’, ‘Z’: ‘Zulu’}encrypted_message = “”# Iterate through each letter in the messagefor letter in message:# If the letter is in the dictionary, add the corresponding codeword to the encrypted messageif letter.upper() in nato_alphabet:encrypted_message += nato_alphabet[letter.upper()] + “ “# If the letter is not in the dictionary, add the original letter to the encrypted messageelse:encrypted_message += letterreturn encrypted_messagemessage = "Hello World"encrypted_message = encrypt_message(message)print("Encrypted message: ", encrypted_message)
社交媒体登录自动化
from selenium import webdriverdriver = webdriver.Firefox()driver.get(“https://www.facebook.com/")# Find the email or phone field and enter the email or phone numberemail_field = driver.find_element_by_id(“email”)email_field.send_keys(“your_email_or_phone”)# Find the password field and enter the passwordpassword_field = driver.find_element_by_id(“pass”)password_field.send_keys(“your_password”)# Find the login button and click itlogin_button = driver.find_element_by_id(“loginbutton”)login_button.click()

本文暂时没有评论,来添加一个吧(●'◡'●)