python 三種方法實現字符串倒序顯示



import pytest
@pytest.fixture()
def init(request):
str_1 = 'hello 8888'
   print('第一種方法')
   str_5 = str_1[::-1]
   print('第二種方法')
    str_6 = list(str_1)
str_6.reverse()



print("替換前的字符串",str_1)
print("第一種倒序排列的字符串",str_5)
print("第二種倒序排列的字符串",''.join(str_6))

@pytest.fixture()
def reverse_zifuchuan():
str_1 = 'hhhhh kkkk gggg'
c = len(str_1) - 1
str_7 = []
while (c > 0):
str_7.append(str_1[c])
c -= 1
print('第三種倒序排列后的字符串', ''.join(str_7))


@pytest.mark.usefixtures("init")
# @pytest.mark.usefixtures("reverse_zifuchuan")
class TestABC:
def test_hello(self):
print("-------------------------")

 

 

# @pytest.mark.usefixtures("init")
@pytest.mark.usefixtures("reverse_zifuchuan")
class TestABC:
def test_hello(self):
print("-------------------------")

 

 

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM