Python如何利用extendleft逆转字符串?

1 个回答|103 次阅读
Coco老师 - 科普专家
擅长:编程教育
#!usr/bin/env python
# encoding:utf-8
import collections
def strReverse(strDemo):
  deque1=collections.deque(strDemo)
  deque2=collections.deque()
  for tmpChar in deque1:
    deque2.extendleft(tmpChar)
  return ''.join(deque2)
print(strReverse('qbitschool.cn'))