【问题标题】:Python - Is there a way to use a greater than operator that is not a comparison operator?Python - 有没有办法使用不是比较运算符的大于运算符?
【发布时间】:2017-11-06 21:29:55
【问题描述】:

我正在尝试制作一个仅打印字符串中大于字符串中此位置的位置的程序,首先我尝试了 > 但它出现了“无效语法”并以红色突出显示。我尝试了比较大于但做同样的事情(因为我没有比较) 我尝试过的:

sentence = ("Mark")
print (sentence[> 1])

我想要它打印的内容: rk

如果您对 Python 中的大于运算符有任何解决方案或替代方案,请告诉我,我会试一试。 :)

【问题讨论】:

    标签: python operators python-3.6 comparison-operators


    【解决方案1】:

    您只需print (sentence[2:]) 为了将来参考和研究,它被称为切片。

    【讨论】:

      猜你喜欢
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-11
      • 2011-08-20
      • 1970-01-01
      相关资源
      最近更新 更多