小编Cod*_*Man的帖子

无法理解为什么字母u前缀我的raw_input()输出

我目前正在学习Python,并编写了一个程序来试验这门语言.但是,每当我使用它时,输出总是在其中有一个字母"u".我正在使用Pyscripter作为我的IDE.

这是我的代码:

print "whats your name"
age = raw_input()
print "Alright, so %r, I just realized what percent-r does actually or is meant for" % (age)
print "What next ur age",
age1 = raw_input()
print "you entered %r " % (age1)
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我看到这样的事情:

>>> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32.

>>> whats your name (i typed kk)

>>> Alright, so u'kk', i just realized what percent-r does actually or is meant for

>>> …
Run Code Online (Sandbox Code Playgroud)

python unicode raw-input

2
推荐指数
1
解决办法
555
查看次数

为什么我的密码检查代码无法正常工作?无论输入如何,它都会提供相同的输出

我做了一个密码检查程序,检查以下标准: -

  • 至少应该有

    • 1个大写
    • 1个小写字母
    • 1个特殊字符
    • 1个号码
  • 应小于100个字符

就是这样.我没有给出任何下限.无论我给出什么输入(正确或不正确),程序都会给我与截图中附带的相同或类似的输出.

对于如: - ,Pratik10,pratik10,pratikten,pr@tiK10我得到的结果相同"Password is fine and valid".

为什么我的程序没有正确检查定义的条件?它甚至没有正确打印密码的计数器.

以下是我的代码:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>

int main()
{
    char x[100];
    int i;
    int uc=0;
    int lc=0;
    int num=0;
    int misc=0;

    printf("enter your password\n");
    scanf("%s",x);

    for(i=0;i<100;i++) {
        if (isalpha(x[i])) {
            if (isupper(x[i])) {
                uc++;
            }
            if (islower(x[i])) {
                lc++;
            }
        }
        if (isdigit(x[i])) {
            num++;
        } …
Run Code Online (Sandbox Code Playgroud)

c string if-statement nested-if

1
推荐指数
1
解决办法
95
查看次数

标签 统计

c ×1

if-statement ×1

nested-if ×1

python ×1

raw-input ×1

string ×1

unicode ×1