鱼C论坛

 找回密码
 立即注册
查看: 604|回复: 2

[已解决]函数的意义查询

[复制链接]
发表于 2019-7-21 15:06:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
def count(*param):
    length = len(param)
    for i in range(length):
        letters = 0
        space = 0
        digit = 0
        others = 0
        for each in param[i]:
            if each.isalpha():#
                letters += 1
            elif each.isdigit():#
                digit += 1
            elif each == ' ':
                space += 1
            else:
                others += 1
        print('第 %d 个字符串共有:英文字母 %d 个,数字 %d 个,空格 %d 个,其他字符 %d 个。' % (i+1, letters, digit, space, others))
            
count('I love fishc.com.', 'I love you, you love me.')

如果我想查询isalpha和isdigit这两个函数里面的内容和说明,需要在idle通过什么方式查询???
最佳答案
2019-7-21 16:14:55
  1. >>> help(str.isalpha)
  2. Help on method_descriptor:

  3. isalpha(self, /)
  4.     Return True if the string is an alphabetic string, False otherwise.
  5.    
  6.     A string is alphabetic if all characters in the string are alphabetic and there
  7.     is at least one character in the string.

  8. >>> help(str.isdigit)
  9. Help on method_descriptor:

  10. isdigit(self, /)
  11.     Return True if the string is a digit string, False otherwise.
  12.    
  13.     A string is a digit string if all characters in the string are digits and there
  14.     is at least one character in the string.
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-21 15:20:10 | 显示全部楼层
如果在idle里面,就是
help(函数名)
但是我建议百度
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-7-21 16:14:55 | 显示全部楼层    本楼为最佳答案   
  1. >>> help(str.isalpha)
  2. Help on method_descriptor:

  3. isalpha(self, /)
  4.     Return True if the string is an alphabetic string, False otherwise.
  5.    
  6.     A string is alphabetic if all characters in the string are alphabetic and there
  7.     is at least one character in the string.

  8. >>> help(str.isdigit)
  9. Help on method_descriptor:

  10. isdigit(self, /)
  11.     Return True if the string is a digit string, False otherwise.
  12.    
  13.     A string is a digit string if all characters in the string are digits and there
  14.     is at least one character in the string.
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-24 03:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表