Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 检查字符串中的值_Python_Python 2.7 - Fatal编程技术网

Python 检查字符串中的值

Python 检查字符串中的值,python,python-2.7,Python,Python 2.7,我正在使用键盘代码在字符串中输入键盘数字以设置数字 DIGIT_BUTTONS = range(58, 68) if action.getId() in DIGIT_BUTTONS: self.EPG_Channel_Number += str(action.getId() - 58) self.getControl(413).setLabel('[B]' + self.EPG_Channel_Number + '[/B]') 当我按下键盘上的按钮1,0,3时,字符串中增加了3个

我正在使用键盘代码在字符串中输入键盘数字以设置数字

DIGIT_BUTTONS = range(58, 68)

if action.getId() in DIGIT_BUTTONS:
   self.EPG_Channel_Number += str(action.getId() - 58)
   self.getControl(413).setLabel('[B]' + self.EPG_Channel_Number + '[/B]')
当我按下键盘上的按钮1,0,3时,字符串中增加了3个数字。现在我想检查字符串中有多少个值


你能给我举个例子看看我如何检查字符串中有多少个值吗?

你可以用一种简单的方法得到长度:

len(self.EPG_Channel_Number)

什么是字符串?这里是字符串
103
len(self.EPG\u Channel\u Number)
-假设这就是您想要的长度。很好,欢迎您,可以接受答案;)@丹尼尔·泽基尔