Removing spaces between strings

This question already has an answer here:

  • How to print without newline or space? 26 answers

  • 您可以轻松地从python3导入打印功能,这比python 2x的打印语句更好

    from __future__ import print_function
    
    str_=raw_input('Enter:')
    for i,k in enumerate(str_):
        if str_[i] != str_[i].upper():
            v=str(str_[i].upper())
            print(v, end='')
        else:
            c= str(str_[i].lower())
            print(c, end='')
    

    str_=raw_input('Enter:')
    
    response="";
    
    for i,k in enumerate(str_):
        if str_[i] != str_[i].upper():
            v=str(str_[i].upper())
            response=response+v
        else:
            c= str(str_[i].lower())
            response=response+c
    print response
    

    尝试将所有字母添加到新字符串变量,然后打印该新变量


    For this solution you'll need to use print from Python 3 . This should work:

    from __future__ import print_function
    
    str_=raw_input('Enter:')
    for i,k in enumerate(str_):
        if str_[i] != str_[i].upper():
            v=str(str_[i].upper())
            print(v, end="")
        else:
            c= str(str_[i].lower())
            print(c, end="")
    
    链接地址: http://www.djcxy.com/p/77216.html

    上一篇: 如何避免python 3x中readline()函数中的新行?

    下一篇: 删除字符串之间的空格