可以使用字符串的rstrip()
方法或者切片操作来实现。这里有两种方法:
方法1:使用rstrip()
方法
s = "hello, world,"
s = s.rstrip(",")
print(s)
方法2:使用切片操作
s = "hello, world,"
if s[-1]
可以使用字符串的rstrip()
方法或者切片操作来实现。这里有两种方法:
方法1:使用rstrip()
方法
s = "hello, world,"
s = s.rstrip(",")
print(s)
方法2:使用切片操作
s = "hello, world,"
if s[-1]