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("-------------------------")

 

 

 



posted @ 2022-03-03 11:11  明天有盼望  阅读(1943)  评论(0)    收藏  举报