Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
class PaymentPage:
def show_payment_options(self):
print("请选择支付方式:")
print("1. 微信支付")
print("2. 支付宝支付")
def wechat_payment(self):
print("跳转至微信支付界面...")
def alipay_payment(self):
print("跳转至支付宝支付界面...")
payment_page = PaymentPage()
payment_page.show_payment_options()
choice = input("请输入数字选择支付方式:")
if choice == '1':
payment_page.wechat_payment()
elif choice == '2':
payment_page.alipay_payment()
else:
print("请输入有效的选项。")
定义了一个名为PaymentPage的类,可以展示支付选项以及跳转至微信支付和支付宝支付界面。在主程序中,实例化了一个 PaymentPage对象,根据用户选择的支付方式调用对应的方法,进行相应的支付界面跳转。
class SearchBox:
def __init__(self):
self.text = ""
def set_text(self, text):
self.text = text
def search(self):
print(f"搜索文本: {self.text}")
class SearchPage:
def __init__(self):
self.search_box = SearchBox()
def enter_search_text(self, text):
self.search_box.set_text(text)
def perform_search(self):
self.search_box.search()
search_page = SearchPage()
search_text = input("请输入要搜索的内容:")
search_page.enter_search_text(search_text)
search_page.perform_search()
与上周搜索界面进行衔接,实现搜索界面中文本框和搜索按钮的实现