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