三种方法:1、Char.IsDigit (aChar) 指示指定字符串中位于指定位置处的字符是否属于十进制数字类别2、Char.IsNumber(aChar) 指示指定字符串中位于指定位置的字符是否属于数字类别3、aChar>='0'&&aChar<='9' 判断aChar是否...
分类:
其他好文 时间:
2016-01-12 21:08:59
阅读次数:
144
所有数据进入程序中都只是一串字节英文字符占一个字节 汉语是两个字节 一字节byte=8bitUnicode字符串为每种语言的每种字符设定了统一并且唯一的二进制编码big = r'This is a \tsting' r表示原,字符串里面是什么就是什么,反斜杠就是反斜杠,并不会转义s.isdigit(...
分类:
编程语言 时间:
2016-01-06 01:29:09
阅读次数:
213
设s是字符串:s.isalnum() 判断所有字符都是数字或者字母s.isalpha() 判断所有字符都是字母s.isdigit() 判断所有字符都是数字s.islower() 判断所有字符都是小写s.isupper() 判断所有字符都是大写s.istitle() 判断所有单词都是首字...
分类:
编程语言 时间:
2015-12-30 21:40:38
阅读次数:
181
#_*_ coding:utf-8 _*_import sys,os,getpass######################对raw_input输入字符类型判断并转化#####################def input_handle(s): if str.isdigit(s): ...
分类:
编程语言 时间:
2015-12-30 00:22:06
阅读次数:
315
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
intfun()
{
intch;
intret=0;
while(isdigit(ch=getchar()))
{
ret=ret*10+ch-48;
}
ungetc(ch,stdin);
returnret;
}
voidfun1()
{
intch;
intret=fun();
printf("%d\n",ret);
ch=getchar();
putc..
分类:
其他好文 时间:
2015-12-28 20:39:38
阅读次数:
172
练习1让用户一直输入数字,如果输入的不是数字就报错,如果输入pc就退出并算出数字之和#!/usr/bin/evnpython
total=0
whileTrue:
input=raw_input(‘inputsomething:‘)
ifinput.isdigit():
total+=int(input)
elifinput==‘pc‘:
break
else:
print"error"
printtotal
分类:
编程语言 时间:
2015-12-17 19:24:44
阅读次数:
164
原题链接在这里:https://leetcode.com/problems/valid-palindrome/注意在用Character.isLetter(s.charAt(i)) 或者 Character.isDigit(s.charAt(i))前需检验 i 是否index out of boun...
分类:
Web程序 时间:
2015-12-03 13:26:38
阅读次数:
144
写一个程序统计输入字符串中:各个数字、空白字符、以及其他所有字符出现的次数。#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>//isspace(),isdigit()
intmain()
{
intspace=0;
intother=0;
intarr[10]={0};
intch=0;
inti=0;
while((ch..
分类:
其他好文 时间:
2015-11-24 06:20:30
阅读次数:
121
//1用JAVA自带的函数publicstaticbooleanisNumericFirst(Stringstr){for(inti=str.length();--i>=0;){if(!Character.isDigit(str.charAt(i))){returnfalse;}}returntrue;}//2用正则表达式publicstaticbooleanisNumericSecond(Stringstr){Patternpattern=Pattern.compile("[0..
分类:
编程语言 时间:
2015-11-04 19:44:00
阅读次数:
132
1,isDigit();是否是数字 char c = '1'; boolean bool = Character.isDigit(c); System.out.println(bool);//true2,isLetter();是否是字母 char c2 = 'a'; boolean boo...
分类:
其他好文 时间:
2015-10-30 20:32:41
阅读次数:
313